usage: $ export PS1='[arguments]'
example: $ export PS1='\u@\h \$'
| arguments | function |
|---|---|
| \d | date (weekday month date) |
| \h | hostname |
| \H | hostname (domain) |
| \j | number of jobs managed by shell |
| \l | basename of the shell's terminal device name |
| \s | name of the shell (basename of $0) |
| \t | time (24h HH:MM:SS) |
| \T | time (12h HH:MM:SS) |
| \@ | time (12h am/pm) |
| \u | username (current user) |
| \v | bash version |
| \V | bash release (version + patchlevel) |
| \w | current working directory |
| \W | current working directory (basename) |
| \! | command history number |
| \# | command number |
| \$ | if root: show # (else $) |
| \nnn | ASCII character (code nnn) |
| \n | new line |
| \r | carriage return |
| \e | escape character (usually color code) |
| \a | bell character |
| \\ | backslash |
| \[ | begin sequence of non-printing characters (like color escape sequences) |
| \] | end sequence of non-printing characters |
make sure to end the sequence of non-printing characters with \[\e[m\]
example: export PS1='\[\e[0;36m\][\[\e[0;35m\]\u\[\e[0;34m\]@\[\e[0;35m\]\\[\e[0;36m\]] \[\e[0;33m\]\w \! \[\e[0;31m\]\$\[\e[m\] '
| argument | color |
|---|---|
| \[\e[0;30m\] | dark gray |
| \[\e[0;31m\] | red |
| \[\e[0;32m\] | green |
| \[\e[0;33m\] | yellow |
| \[\e[0;34m\] | blue |
| \[\e[0;35m\] | purple |
| \[\e[0;36m\] | cyan |
| \[\e[0;37m\] | light gray |
| \[\e[1;30m\] | blod dark gray |
| \[\e[1;31m\] | blod red |
| \[\e[1;32m\] | blod green |
| \[\e[1;33m\] | blod yellow |
| \[\e[1;34m\] | blod blue |
| \[\e[1;35m\] | blod purple |
| \[\e[1;36m\] | blod cyan |
| \[\e[1;37m\] | blod light gray |
for a single user:
edit the .profiles file in the user's home directory and add it at the bottom
for all non-root users:
(as root) create a bash script file in /etc/profile.d/ (e.g. /etc/profile.d/custom_prompt.sh)
and add export PROMPT_COMMAND='export PS1="[arguments]"'