Bash prompts

Normal user promptroot promptToday I once again did something really stupid while being logged in as root. I already had my root and normal user bash prompts colored differently, but it turns out that the difference was not obvious enough. So, I decided to recolor the prompts a little bit more vividly.

It took me few minutes to refresh my memory with Bash Prompt HOWTO. After that I came up with this snippet in .bashrc of the normal user (left screenshot):

# Cyan on blue time and Yellow on blue user@host dir
export PS1="\n\[\033[44;1;36m\][\$(date +%H:%M)]\[\033[44;1;33m\][\u@\h \W]\[\033[0m\]$ "
export PS2="\[\033[44;1;36m\][\$(date +%H:%M)]\[\033[44;1;33m\][\u@\h \W]\[\033[0m\]> "

Root’s prompt (right screenshot) was a bliss after that:

# Cyan on red time and yellow on red username@host dir
export PS1="\n\[\033[41;1;36m\][\$(date +%H:%M)]\[\033[41;1;33m\][\u@\h \W]\[\033[0m\]# "
export PS2="\[\033[41;1;36m\][\$(date +%H:%M)]\[\033[41;1;33m\][\u@\h \W]\[\033[0m\]> "

Leave a Comment