[Solved] Constructed a multi-purpose prompt but still have 1 issue

I didn't think re-opening my old thread was a good idea so I'm starting  new one to address 1 issue I have left to conquer.
With some help from JWR I have built my prompt and it works for users and root logged into a local machine.  Logging into a remote machine does change my user's prompt by appending :ssh: to it.  However, as the root user logged into a remote machine, which should have the  :ssh: appended to it, doesn't work.  By that I mean that root logged in to a remote system doesn't get the correct prompt.  I want the prompt to look like this for root:
:root: ~ :ssh:
Instead I get this prompt which lacks the word "root" in it:
: ~ ::ssh:
This is my prompt script so far and I'd really appreciate some help to nail down this glitch. 
The script for root and user are identical apart from having a different prompt uncommented.
### Other prompt styles to use later
This is root's current script:
### A PS1 for each computer is on the respective lines in this order:
### ### White Yunzi / Silver Yunzi / Pink Yunzi / Rainbow EeePC
if [[ -n $SSH_CLIENT ]]; then
# PS1='\[\e[0;37m\]: \[\e[1;32m\]\W\[\e[0;37m\] :\[\e[0;37m\]:\[\e[1;33m\]ssh\[\e[m\]\[\e[0;37m\]: ' # WY SSH
PS1='\[\e[0;37m\]: \[\e[1;33m\]\W\[\e[0;37m\] :\[\e[0;37m\]:\[\e[1;33m\]ssh\[\e[m\]\[\e[0;37m\]: ' # SY SSH
# PS1='\[\e[0;37m\]: \[\e[1;35m\]\W\[\e[0;37m\] :\[\e[0;37\m]:\[\e[1;33m\]ssh\[\e[m\]\[\e[0;37m\]: ' # PY SSH
# PS1='\[\e[0;37m\]: \[\e[1;33m\]\W\[\e[0;37m\] :\[\e[0;37m\]:\[\e[1;33m\]ssh\[\e[m\]\[\e[0;37m\]: ' # EeePC SSH
elif [[ ${EUID} == 0 ]]; then ## :root: ~ :
# PS1='\[\e[0;37m\]:\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;92m\]\W \[\e[0;37m\]:\[\e[m\] \[\e[0;37m\] ' # WY root
PS1='\[\e[0;37m\]:\[\e[1;34m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;34m\]\W \[\e[0;37m\]:\[\e[m\] \[\e[0;37m\] ' # SY root
# PS1='\[\e[0;37m\]:\[\e[1;35m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;35m\]\W \[\e[0;37m\]:\[\e[m\] \[\e[0;37m\] ' # PY root
# PS1='\[\e[0;37m\]:\[\e[1;33m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;33m\]\W \[\e[0;37m\]:\[\e[m\] \[\e[0;37m\] ' # EeePC root
else ## : ~ :
# PS1='\[\e[0;37m\]: \[\e[1;32m\]\W\[\e[0;37m\] :\[\e[m\]\[\e[0;37m\] ' # WY user
PS1='\[\e[0;37m\]: \[\e[1;34m\]\W\[\e[0;37m\] :\[\e[m\]\[\e[0;37m\] ' # SY user
# PS1='\[\e[0;37m\]: \[\e[1;35m\]\W\[\e[0;37m\] :\[\e[m\]\[\e[0;37\m] ' # PY user
# PS1='\[\e[0;37m\]: \[\e[1;33m\]\W\[\e[0;37m\] :\[\e[m\]\[\e[0;37m\] ' # EeePC user
fi
## :root: ~ :ssh:
#PS1='\[\e[0;37m\]:\[\e[1;34m\]\u\[\e[0;37m\]:\[\e[1;34m\] \W \[\e[0;37m\]:\[\e[m\]\[\e[0;37m\]\[\e[1;33m\]ssh\[\e[0;37m\]: ' # SY root
## :root:: ~ :ssh:
#PS1='\[\e[0;37m\]:\[\e[1;34m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;34m\]\W \[\e[0;37m\]:\[\e[m\]\[\e[0;37m\]\[\e[1;33m\]ssh\[\e[0;37m\]: ' # SY root
## :root:: ~ ::ssh:
# PS1='\[\e[0;37m\]:\[\e[1;34m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;34m\]\W\[\e[0;37m\] :\[\e[m\]:\[\e[m\]\[\e[0;37m\]\[\e[1;33m\]ssh\[\e[0;37m\]: ' # SY root
Last edited by MoonSwan (2014-11-19 09:23:02)
Advertisement
Reply

jasonwryan wrote:So it works for root locally, just not when you SSH in as root or change to root in an SSH session?
Yes, you're quite correct.
jasonwryan wrote:Also, it might help if you remove the commented lines, it is pretty hard to work out what is going on in there...
I agree and I found a bunch of \'s that I missed.  Sorry about that!
Here's the config stripped of extraneous junk:
if [[ -n $SSH_CLIENT ]]; then
PS1='\[\e[0;37m\]: \[\e[1;32m\]\W\[\e[0;37m\] :\[\e[0;37m\]:\[\e[1;33m\]ssh\[\e[m\]\[\e[0;37m\]: ' # WY SSH
elif [[ ${EUID} == 0 ]]; then ## :root: ~ :
PS1='\[\e[0;37m\]:\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[0;37m\]: \[\e[1;92m\]\W \[\e[0;37m\]:\[\e[m\] \[\e[0;37m\] ' # WY root
else
PS1='\[\e[0;37m\]: \[\e[1;32m\]\W\[\e[0;37m\] :\[\e[m\]\[\e[0;37m\] ' # WY user
fi
Edit:  stripped out two comments I'd missed earlier.
Last edited by MoonSwan (2014-11-19 08:27:27)