The Bash supports four different prompts:
PS1
is the usual prompt when interactively entering commandsPS2
is used, when a command spans multiple lines (e.g. if a string is still open when you press ENTER or after a Backslash)PS3
is used for shell menues withselect
PS4
is prepended for execution traces (see Bash Debugging)
The Prompts PS1
, PS2
and PS4
support placeholders that are replaced with current information
such as the hostname, the username or the working directory
(the full list is in the Bash man page and documentation).
Symbol | Description |
---|---|
\h |
Hostname |
\u |
User name |
\w |
Current working directory |
\@ |
The character "@" |
\$ |
For root "#", otherwise "$" |
An example prompt:
PS1='\u@\h:\w$ '
This prints the username, "@" hostname, a colon, the working directory and a dollar sign (followed by a space).
Example for a colored prompt:
export PS1='\[\033[1;34m\]\u\[\033[0m\]@\[\033[0;32m\]\h\[\033[0m\]:\[\033[1;33m\]\w\[\033[0m\]$ '