The primary prompt string, printed before a command is read; the
default is "%m%# ". If the escape sequence takes an optional
integer, it should appear between the `%' and the next character of
the sequence. The following escape sequences are recognized:
- %d
%/
-
Present working directory ($PWD).
- %~
-
$PWD. If it has a named directory as its prefix, that part is replaced
by a ~ followed by the name of the directory. If it starts with $HOME,
that part is replaced by a ~.
- %c
%.
%C
-
Trailing component of $PWD. An integer may follow the `%' to get more
than one component. Unless %C is used, tilde expansion is
performed first.
- !
%h
%!
- Current history event number.
- %M
- The full machine hostname.
- %m
-
The hostname up to the first `.'. An integer may follow the `%' to
specify how many components of the hostname are desired.
- %S (%s)
- Start (stop) standout mode.
- %U (%u)
- Start (stop) underline mode.
- %B (%b)
- Start (stop) boldface mode.
- %t
%@
- Current time of day, in 12-hour, am/pm format.
- %T
- Current time of day, in 24-hour format.
- %*
- Current time of day in 24-hour format, with seconds.
- %n
- $USERNAME.
- %w
- The date in day-dd format.
- %W
- The date in mm/dd/yy format.
- %D
- The date in yy-mm-dd format.
- %D{string}
-
string is formatted using the strftime function. See strftime(3) for
more details, if your system has it.
- %l
- The line (tty) the user is logged in on.
- %?
- The return code of the last command executed just before the prompt.
- %_
-
The status of the parser, i.e. the shell constructs (like `if' and
`for') that have been started on the command line. If given an integer
number that many strings will be printed.
- %E
- Clears to end of line.
- %#
-
A `#' if the shell is running as root, a `%' if not. Equivalent to %(#.#.%%).
- %v
-
The value of the first element of the $psvar array
parameter. Following the `%' with an integer gives that element of the
array.
- %{...%}
-
Include a string as a literal escape sequence. The string within the
braces should not change the cursor position.
- %(x.true-text.false-text)
-
Specifies a ternary expression. The character following the x
is arbitrary; the same character is used to separate the text for the
"true" result from that for the "false" result. Both
the separator and the right parenthesis may be escaped with a
backslash. True-text and false-text may
both contain arbitrarily-nested escape sequences, including further
ternary expressions. The left parenthesis may be preceded or followed
by a positive integer n, which defaults to zero. The test
character x may be any of the following:
- c
.
~
-
True if the current path, with prefix replacement, has at least
n elements.
- /
C
-
True if the current absolute path has at least n elements.
- t
- True if the time in minutes is equal to n.
- T
- True if the time in hours is equal to n.
- d
- True if the day of the month is equal to n.
- D
- True if the month is equal to n (January = 0).
- w
- True if the day of the week is equal to n (Sunday = 0).
- ?
- True if the exit status of the last command was n.
- #
- True if the effective uid of the current process is n.
- g
- True if the effective gid of the current process is n.
- L
- True if the SHLVL parameter is at least n.
- S
- True if the SECONDS parameter is at least n.
- v
- True if the array psvar has at least n elements.
- _
- True if at least n shell constructs were started.