Monday, November 04, 2013

I wanted a bash prompt that changed based on if I was user or root, but without specifying the username becasue my username is rather long a more compact prompt would be nice. On the mac the hostname changes with dhcp so I just specified what I wanted the machine ot appear as in my prompt.

settled on:

PS1='$(if [[ $USER == root ]]; then  echo "\[\033[0;91m\]R\[\033[0;0m\]@\[\033[0;33m\]mb-aye\[\033[0m\]:\W#"; else echo "\[\033[0;92m\]J\[\033[0;0m\]@\[\033[0;33m\]mb-aye\[\033[0m\]:\W$"; fi)'

R@mb-aye:jjaeggli#

J@mb-aye:~$