Next: The Restricted Shell, Previous: The Directory Stack, Up: Bash Features [Contents][Index]
The value of the variable PROMPT_COMMAND
is examined just before
Bash prints each primary prompt. If PROMPT_COMMAND
is set and
has a non-null value, then the
value is executed just as if it had been typed on the command line.
In addition, the following table describes the special characters which
can appear in the prompt variables PS0
, PS1
, PS2
, and
PS4
:
\a
\d
\D{format}
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.\e
\h
\H
\j
\l
\n
\r
\s
$0
(the portion following the final slash).\t
\T
\@
\A
\u
\v
\V
\w
$HOME
abbreviated with a tilde (uses the $PROMPT_DIRTRIM
variable).\W
$PWD
, with $HOME
abbreviated with a tilde.\!
\#
\$
#
, otherwise $
.\nnn
nnn
.\\
\[
\]
The command number and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file (see Bash History Facilities), while the command number is the position in the sequence of commands executed during the current shell session.
After the string is decoded, it is expanded via
parameter expansion, command substitution, arithmetic
expansion, and quote removal, subject to the value of the
promptvars
shell option (see The Shopt Builtin).
This can have unwanted side effects if escaped portions of the string
appear within command substitution or contain characters special to
word expansion.
Next: The Restricted Shell, Previous: The Directory Stack, Up: Bash Features [Contents][Index]