ss64.com seems to have the best reference I've found.
It explains the following variables:
\d The date, in "Weekday Month Date" format (e.g., "Tue May 26").
\h The hostname, up to the first . (e.g. deckard)
\H The hostname. (e.g. deckard.SS64.com)
\j The number of jobs currently managed by the shell.
\l The basename of the shell's terminal device name.
\s The name of the shell, the basename of $0 (the portion following
the final slash).
\t The time, in 24-hour HH:MM:SS format.
\T The time, in 12-hour HH:MM:SS format.
\@ The time, in 12-hour am/pm format.
\u The username of the current user.
\v The version of Bash (e.g., 2.00)
\V The release of Bash, version + patchlevel (e.g., 2.00.0)
\w The current working directory.
\W The basename of $PWD.
\! The history number of this command.
\# The command number of this command.
\$ If you are not root, inserts a "$"; if you are root, you get a "#" (root uid = 0)
\nnn The character whose ASCII code is the octal value nnn.
\n A newline.
\r A carriage return.
\e An escape character.
\a A bell character.
\\ A backslash.
\[ Begin a sequence of non-printing characters. (like color escape sequences). This
allows bash to calculate word wrapping correctly.
\] End a sequence of non-printing characters.
The \[ ... \]
defines a series of non-printing characters. They are required to keep track of the cursor position correctly.
The \e
in your prompt starts an escape sequence. More on those here (note "Esc" on that page is the \e
sequence).
- Note: I've never really liked escape sequences. Use
tput
to get the escape code for you.
${debian_chroot:+($debian_chroot)}
is parameter expansion. See here
- It writes
($debian_chroot)
if $debian_chroot
is set otherwise nothing.
PS1
in a terminal, e.g.PS1="How r u, \u?"
. The change will only last until you close the terminal.