3 ms·
I do that in bash for root/non-root users (root is red, non-root is blue): if [[ ${EUID} == 0 ]] ; then PS1='\[\033[01m\][ \[\033[01;31m\]\u@\h \[\
by jonhohle 16y ago
I do that in bash for root/non-root users (root is red, non-root is blue):
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01m\][ \[\033[01;31m\]\u@\h \[\033[00m\]\[\033[01m\]] \[\033[01;32m\]\w\[\033[00m\]\n\[\033[01;31m\]\$\[\033[00m\]> '
else
PS1='\[\033[01m\][ \[\033[01;34m\]\u@\h \[\033[00m\]\[\033[01m\]] \[\033[01;32m\]\w\[\033[00m\]\n\[\033[01;34m\]\$\[\033[00m\]> '
fi
Interesting to think about using it across servers, though.
- s-phi-nl 16y agoKonsole does this automatically, at least on openSuSE linux.
- pmjordan 16y agoIt's actually just the default bash config on openSUSE, nothing to do with Konsole. It works on text-mode VTs, via ssh, etc.
- mgedmin 16y agoI used to have a different prompt color when SSH_CONNECTION was in my environment, to distinguish local terminals from remote connections. And also root/non-root, although I didn't know about $EUID and used the less-effective $(id -u).