- PS1: The default promt you see when you open a shell
It's value is stored in an environment variable calledPS1. To see its value, type
echo $PS1
This will give you something like
To change it, you can set a new value for the variable:\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
This will result in a prompt like this:export PS1="\u > "
stefano > - PS2: is your secondary prompt. This get's shown when a command is not finished.
Type
echo "asdand hit enter, the secondary prompt will let you enter more lines until you close the inverted commas. - PS3 is the prompt used for
select(2) - PS4 is the prompt used for
stack traces (default:
+)
.bash_profile (or .bashrc, see this question) in your
home directory.Here's a more or less complete list of shorthand that you can use when composing these:
\aThe 'bell' charakter\A24h Time\dDate (e.g. Tue Dec 21)\eThe 'escape' charakter\hHostname (up to the first ".")\HHostname\jNo. of jobs currently running (ps)\lCurrent tty\nLine feed\tTime (hh:mm:ss)\TTime (hh:mm:ss, 12h format)\rCarriage return\sShell (i.e. bash, zsh, ksh..)\uUsername\vBash version\VFull Bash release string\wCurrent working directory\WLast part of the current working directory\!Current index in history\#Command index\$A "#" if you're root, else "$"\\Literal Backslash\@Time (12h format with am/pm)
export PS1="\u \$(pwd) > "
Where $(pwd) stands in place of "the output of" pwd.- If the command substitution is escaped, as in
\$(pwd), it's evaluated every time the prompt is displayed, otherwise, as in$(pwd), it's only evaluated once when bash is started.
40;33;01
- The first part before the semicolon represents the text style.
- 00=none
- 01=bold
- 04=underscore
- 05=blink
- 07=reverse
- 08=concealed
- The second and third part are the colour and the background color:
- 30=black
- 31=red
- 32=green
- 33=yellow
- 34=blue
- 35=magenta
- 36=cyan
- 37=white
\33[ and ending it with an m. 33, or 1B in hexadecimal, is the ascii sign "ESCAPE" (a special character in the ascii character set). Example:"\33[1;31mHello World\33[m"
Prints "Hello World" in bright red.
Aucun commentaire:
Enregistrer un commentaire