Page 1 of 1

Changing my PS1 variable in SSH?

Posted: Tue Jun 26, 2012 3:55 pm
by zgold
I can't seem to modify the PS1/PLAINPS1 variables that are set in SSH.

Personally, I think this looks awful:

Code: Select all

_[Sonic:/home/z/zgold]_
$ 
and I want to change it to this:

Code: Select all

[zgold@bolt ~]$ 
I attempted to put this into my .bash_profile and .bashrc:

Code: Select all

PS1="[\u@\h \W] $ "
PLAINPS1="[\u@\h \W] $ "
... but it doesn't run upon login.

Any ideas?

Re: Changing my PS1 variable in SSH?

Posted: Tue Jun 26, 2012 4:56 pm
by joemuller
It might be failing because the square brackets aren't escaped with a backslash '\'. Try the following:

Code: Select all

PS1="\[\u@\h: \w\] $ "

Re: Changing my PS1 variable in SSH?

Posted: Tue Jun 26, 2012 5:15 pm
by zgold
joemuller wrote:It might be failing because the square brackets aren't escaped with a backslash '\'. Try the following:

Code: Select all

PS1="\[\u@\h: \w\] $ "
Nope, that didn't work either. :(

Re: Changing my PS1 variable in SSH?

Posted: Tue Jun 26, 2012 6:04 pm
by joemuller
I was able to get it to work once with this:

Code: Select all

PS1="[\u@\h \w] $ "
I'm not sure why the PS1 variable is being clobbered, but it's happening to me too! :-(

Re: Changing my PS1 variable in SSH?

Posted: Tue Jun 26, 2012 7:03 pm
by zgold
Image

Re: Changing my PS1 variable in SSH?

Posted: Thu Jun 28, 2012 2:30 pm
by joemuller
With a bit of help, I figured out a way to make it work:

The first thing you'll need to do is remove your .bash_profile:

Code: Select all

rm ~/.bash_profile
Then, we create a symlink to your bashrc file:

Code: Select all

ln -s ~/.bashrc ~/.bash_profile
Finally, change your line with PS1 to be the following:

Code: Select all

export PS1="[\u@\h \w] $ "
The important part is that the 'export' portion exists. The changes should take effect the next time you log in.

Re: Changing my PS1 variable in SSH?

Posted: Thu Jun 28, 2012 2:48 pm
by zgold
Works! Thank you!