Special Prompt Strings
Both shells process the value of PS1 for special strings. The
Korn shell expands a single !
into the current command number. Use !! to get a literal !. For example:
PS1='cmd !> '
Bash processes the values of PS1, PS2, and PS4 for the following special escape sequences.
|
|
An ASCII BEL character (octal 07). |
|
|
The current time in 24-hour HH:MM format. |
|
|
The date in “weekday month day” format. |
|
|
The date as specified by the strftime(3) format format. The braces are required. |
|
|
An ASCII Escape character (octal 033). |
|
|
The hostname, up to the first period. |
|
|
The full hostname. |
|
|
The current number of jobs. |
|
|
The basename of the shell’s terminal device. |
|
|
A newline character. |
|
|
A carriage return character. |
|
|
The name of the shell (basename of
|
|
|
The current time in 24-hour HH:MM:SS format. |
|
|
The current time in 12-hour HH:MM:SS format. |
|
|
The current user’s username. |
|
|
The version of Bash. |
|
|
The release (version plus patchlevel) of Bash. |
|
|
The current directory, with $HOME
abbreviated as |
|
|
The basename of the current
directory, with $HOME abbreviated as |
|
|
The history number of this command. |
|
|
The command number of this command. |
|
|
If the effective UID is 0, a
|
|
|
The current time in 12-hour a.m./p.m. format. |
|
|
The character represented by octal value nnn. |
|
|
A literal backslash. |
|
|
Start a sequence of nonprinting ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access