Go to the previous, next section.

Controlling the Prompt

The value of the variable $PROMPT_COMMAND is examined just before Bash prints each primary prompt. If it is set and non-null, then the value is executed just as if you had typed it on the command line.

In addition, the following table describes the special characters which can appear in the PS1 variable:

\t
the time, in HH:MM:SS format.
\d
the date, in "Weekday Month Date" format (e.g. "Tue May 26").
\n
newline.
\s
the name of the shell, the basename of $0 (the portion following the final slash).
\w
the current working directory.
\W
the basename of $PWD.
\u
your username.
\h
the hostname.
\#
the command number of this command.
\!
the history number of this command.
\nnn
the character corresponding to the octal number nnn.
\$
if the effective uid is 0, #, otherwise $.
\\
a backslash.
\[
begin a sequence of non-printing characters. This could be used to embed a terminal control sequence into the prompt.
\]
end a sequence of non-printing characters.

Go to the previous, next section.