bash: Controlling the Prompt

1 
1 6.9 Controlling the Prompt
1 ==========================
1 
1 The value of the variable 'PROMPT_COMMAND' is examined just before Bash
1 prints each primary prompt.  If 'PROMPT_COMMAND' is set and has a
1 non-null value, then the value is executed just as if it had been typed
1 on the command line.
1 
1    In addition, the following table describes the special characters
1 which can appear in the prompt variables 'PS1' to 'PS4':
1 
1 '\a'
1      A bell character.
1 '\d'
1      The date, in "Weekday Month Date" format (e.g., "Tue May 26").
1 '\D{FORMAT}'
1      The FORMAT is passed to 'strftime'(3) and the result is inserted
1      into the prompt string; an empty FORMAT results in a
1      locale-specific time representation.  The braces are required.
1 '\e'
1      An escape character.
1 '\h'
1      The hostname, up to the first '.'.
1 '\H'
1      The hostname.
1 '\j'
1      The number of jobs currently managed by the shell.
1 '\l'
1      The basename of the shell's terminal device name.
1 '\n'
1      A newline.
1 '\r'
1      A carriage return.
1 '\s'
1      The name of the shell, the basename of '$0' (the portion following
1      the final slash).
1 '\t'
1      The time, in 24-hour HH:MM:SS format.
1 '\T'
1      The time, in 12-hour HH:MM:SS format.
1 '\@'
1      The time, in 12-hour am/pm format.
1 '\A'
1      The time, in 24-hour HH:MM format.
1 '\u'
1      The username of the current user.
1 '\v'
1      The version of Bash (e.g., 2.00)
1 '\V'
1      The release of Bash, version + patchlevel (e.g., 2.00.0)
1 '\w'
1      The current working directory, with '$HOME' abbreviated with a
1      tilde (uses the '$PROMPT_DIRTRIM' variable).
1 '\W'
1      The basename of '$PWD', with '$HOME' abbreviated with a tilde.
1 '\!'
1      The history number of this command.
1 '\#'
1      The command number of this command.
1 '\$'
1      If the effective uid is 0, '#', otherwise '$'.
1 '\NNN'
1      The character whose ASCII code is the octal value NNN.
1 '\\'
1      A backslash.
1 '\['
1      Begin a sequence of non-printing characters.  This could be used to
1      embed a terminal control sequence into the prompt.
1 '\]'
1      End a sequence of non-printing characters.
1 
1    The command number and the history number are usually different: the
1 history number of a command is its position in the history list, which
11 may include commands restored from the history file (⇒Bash History
 Facilities), while the command number is the position in the sequence
1 of commands executed during the current shell session.
1 
1    After the string is decoded, it is expanded via parameter expansion,
1 command substitution, arithmetic expansion, and quote removal, subject
1 to the value of the 'promptvars' shell option (⇒Bash Builtins).
1