Special Prompt Strings
- The ASCII BEL character, which is octal
- An ASCII Escape character, which is octal
- The hostname, up to the first period.
- The full hostname.
- A newline character, which is octal
- A carriage return character, which is octal
- The current time in 24-hour
- The current time in 12-hour
- The current user’s username.
- The character represented by the octal value
- Start a sequence of nonprinting characters, such as for highlighting or changing colour on a terminal.
- End a sequence of nonprinting characters.
# configure the Bash startup file ~/.bashrc
# - set prompt string: [time]user@host:path$
# - set prompt colour: blue if last return value is 0; red otherwise
PS1="\`if (( \$? == 0 )); then echo '\[\e[0;34m\][\t]\u@\h:\w\\$'
else echo '\[\e[0;31m\][\t]\u@\h:\w\$'; fi\` \[\e[m\]"