Changing my PS1 variable in SSH?

General discussions and other topics.
7 posts Page 1 of 1
by zgold » Tue Jun 26, 2012 3:55 pm
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?
by joemuller » Tue Jun 26, 2012 4:56 pm
It might be failing because the square brackets aren't escaped with a backslash '\'. Try the following:

Code: Select all

PS1="\[\u@\h: \w\] $ "
I'm a proud employee of Sonic.net! :-)
by zgold » Tue Jun 26, 2012 5:15 pm
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. :(
by joemuller » Tue Jun 26, 2012 6:04 pm
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! :-(
I'm a proud employee of Sonic.net! :-)
by zgold » Tue Jun 26, 2012 7:03 pm
Image
by joemuller » Thu Jun 28, 2012 2:30 pm
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.
I'm a proud employee of Sonic.net! :-)
by zgold » Thu Jun 28, 2012 2:48 pm
Works! Thank you!
7 posts Page 1 of 1

Who is online

In total there are 85 users online :: 0 registered, 0 hidden and 85 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 85 guests