I want to use the PS1 setting in my .bashrc file to change the color of the terminal based on whether I'm on my local machine or using ssh.
My current .bashrc file on both my local machine and the ssh server is (the default):
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
I've tried adding "\e[40m"
to the end, but only changes part of the background of the terminal, leaving a black bar in the middle
How would I go about changing the PS1 setting to, say, my local terminal is dark blue and the ssh terminal is dark gray?
Thanks!
Just out of curiosity, doesn't that remote machine set its own
PS1
value which means however you set your prompt locally, that remote machine will override it?One way around this is to setup a function to replace your actual
ssh
command. Have that function set the color of your terminal, and then run the actualssh
command:Now, create an alias:
Now, when you run
ssh
, it will run yourssh_function
which sets the screen color before executingssh
and then resets your screen colors once out ofssh
. Theclear
is to clear your terminal, so you get a constant color. Otherwise, it merely resets the color at your prompt.And then hope that the remote
PS1
environment variable doesn't reset the terminal color on you.