概述
原文地址https://www.dyxmq.cn/linux/xshell-color-prompt.html
设置前显示如下
设置后显示
修改用户目录下的.bashrc
文件,每个用户家目录下的对应文件都需要修改(修改一个只对应一个用户的,其他用户的不会变),vi .bashrc
然后做如下修改
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
#上面是centos中原来的内容,下面是新加的(Ubuntu中有下面的内容,去掉一行注释就行,具体我也不知道啥道理,只是试了可以用)
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes #Ubuntu中只需要将这行的注释去掉就行
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[ 33[01;32m]u@h[ 33[00m]:[ 33[01;34m]w[ 33[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
fi
unset color_prompt force_color_prompt
最后
以上就是贤惠鸡为你收集整理的xshell中主机名和用户名颜色设置的全部内容,希望文章能够帮你解决xshell中主机名和用户名颜色设置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复