Hack 37. Change foreground color of the prompt
by Ramesh
Display prompt in blue color, along with username, host and current directory information
- $ export PS1="\e[0;34m\u@\h \w> \e[m "
- [Note: This is for light blue prompt]
- $ export PS1="\e[1;34m\u@\h \w> \e[m "
- [Note: This is for dark blue prompt]
- \e[ – Indicates the beginning of color prompt
- x;ym – Indicates color code. Use the color code values mentioned below.
- \e[m – indicates the end of color prompt
Color Code Table:
- Black 0;30
- Blue 0;34
- Green 0;32
- Cyan 0;36
- Red 0;31
- Purple 0;35
- Brown 0;33
[Note: Replace 0 with 1 for dark color]
Make the color change permanent by adding the following lines your ~/.bash_profile or ~/.bashrc
- $ vi ~/.bash_profile
- STARTCOLOR='\e[0;34m';
- ENDCOLOR="\e[0m"
- export PS1="$STARTCOLOR\u@\h \w> $ENDCOLOR"
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .