- 設置檔
- 全users
/etc/profile or /etc/bashrc
- 個別user
~/.bash_profile , ~/.bash_login , ~/.profile , ~/.bashrc or ~/.bash_logout
- 全users
- 客製化prompt
PS1='[\u@\h \w] \$ # ' #即為user@host ~
PS1="\e[\u@\h \w]$ \e]" #即為[user@host ~]
加框'[', ']',由於是key words所以要加\e
而0;32m 是指顏色,其他以此類推應該就看的出來了
- 加上顏色
PS1="\e[0;32m[\u@\h \w]\e]$ \e[m]" #即為[user@host ~]
- 啟使
source .bashrc
or
. .bashrc - Changing foreground and background bash prompt colors
Syntax for changing colors in the bash is as follows:
\033[ -> Indicates the beginning of color in the text x;yzm - Indicates color code \033[00m - Indicates the end of color in the text
截錄常用的字元代表意思
Bash special character | Bash special character explanation | Bash special character | Bash special character explanation |
---|---|---|---|
\] | end a sequence of non-printing characters | \[ | begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt |
\h | the hostname up to the first `.' | \H | the hostname |
\s | the name of the shell, the basename of $0 (the portion following the final slash) | \l | the basename of the shell's terminal device name |
\$ | if the effective UID is 0, a #, otherwise a $ | \u | the username of the current user |
\w | the current working directory | \W | the basename of the current working directory |
\D{format} | the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required |
個人配置檔
#prompt if [ $TERM = 'xterm' ] then PS1='\e[0;32m[\[\033[02;32m\]\u@\h\[\033[01;34m\] \w\e[0;32m]\$\e[m ' else PS1='[\u@\h \w] \$ # ' fi # colorful man page export PAGER="`which less` -s" export BROWSER="$PAGER" export LESS_TERMCAP_mb=$'\E[01;36m' export LESS_TERMCAP_md=$'\E[01;36m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;33m'
References
Bash prompt basics
沒有留言:
張貼留言