Scientific Linux是重新编译的Red Hat Enterprise Linux,由费米国家加速器实验室、欧洲核研究组织以及世界各地的大学和实验室共同开发。它旨在与Red Hat Enterprise Linux完全兼容,也强调自主方便的定制,用户可以根据自己的需求做相应修改,可以使用脚本或者Anaconda给自己定制最小化的安装模式。
全部博文(89)
分类: LINUX
2009-07-21 10:03:53
(用不同的颜色显示不同的用户,我喜欢超级用户是红色的,并且将当前路径全部显示。)
To change the colour of the BASH shell prompt for yourself only, you can edit your ~/.bashrc
file by adding the following to the end:
This is the same principle as the above, but log in as root first and add the following to the end of root's ~/.bashrc
:
if [ $TERM = 'xterm' ]
then
PS1='\[\033[01;31m\]\u@\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\u@\h \w \$ '
fi
Changing the default setting for new users
If you want to make this change apply to all existing users (unless otherwise overridden by their local ~/.bashrc
file) you need to edit the /etc/bashrc
file. The particular section you need to edit looks like this:
if [ "$PS1" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi
After some playing around with it, I couldn't work out how to modify the PROMPT_COMMAND value correctly, but adding in the PS1 setting directly underneath it did the trick:
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"' PS1='\[\033[02;32m\]\u@\h\[\033[02;34m\] \w \$\[\033[00m\] '