BashHandling the system prompt


Syntax

  • export PS1="something" # displayes when bash awaits a command to be typed in
  • export PS2="anotherthing" # dsplayed when statement extends to more lines
  • export PS3="question prompt for select statement" # seldomly used prompt for select. First set PS3 to your needs, then call select. See help select
  • export PS4="mostly useful for debugging; line number and so on" # used for debugging bash scripts.

Parameters

EscapeDetails
\aA bell character.
\dThe date, in "Weekday Month Date" format (e.g., "Tue May 26").
\D{FORMAT}The 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.
\eAn escape character. \033 works of course too.
\hThe hostname, up to the first `.'. (i.e. no domain part)
\HThe hostname eventually with domain part
\jThe number of jobs currently managed by the shell.
\lThe basename of the shell's terminal device name.
\nA newline.
\rA carriage return.
\sThe name of the shell, the basename of `$0' (the portion following the final slash).
\tThe time, in 24-hour HH:MM:SS format.
\TThe time, in 12-hour HH:MM:SS format.
@The time, in 12-hour am/pm format.
\AThe time, in 24-hour HH:MM format.
\uThe username of the current user.
\vThe version of Bash (e.g., 2.00)
\VThe release of Bash, version + patchlevel (e.g., 2.00.0)
\wThe current working directory, with $HOME abbreviated with a tilde (uses the $PROMPT_DIRTRIM variable).
\WThe basename of $PWD, with $HOME abbreviated with a tilde.
!The history number of this command.
#The command number of this command.
$If the effective uid is 0, #, otherwise $.
\NNNThe character whose ASCII code is the octal value NNN.
\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.