First, let's take a look at the original setup prompt ~ In the bashrc configuration file, the initial definition is as follows: setafancyprompt (non-color, unlessweknow
First, let's take a look at the original setup prompt, in the ubuntu feisty ~ /. In the bashrc configuration file, the initial definition is as follows:
- # Set a fancy prompt (non-color, unless we know we "want" color)
- Case "$ TERM" in xterm-color)
- PS1 = '$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u @ h [33 [00 m]: [33 [01; 34 m] w [33 [00 m] $'
- ;;
- *)
- PS1 = '$ {debian_chroot: + ($ debian_chroot)} u @ h: w $'
- ;;
- Esac
Let's only look at this line:PS1 = '$ {debian_chroot: + ($ debian_chroot)} u @ h: w $'
Environment variable:
Note:$ {Xxxx} is a variable, u represents the current user, h represents the host name, w represents the working path, and $ is '$' (escape symbol, such as n, t)
Color code:
[33 [01; 32 m] is a standard color code consisting of a semi-Square brackets. The second '[' is followed by the standard ANSI color code.
My shell prompt is like this:
- PS1 = '$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u [33 [01; 35 m] @ [33 [01; 36 m] h [33 [00 m]: [33 [01; 34 m] wn [33 [01; 39 m] $? [33 [01; 38 m] $'
[$? Returns the return code of the last operation. 0 indicates that the operation is successful.]