Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I ssh into a remote server, I like the colors of the terminal to change. I use setterm on my remote ~/.bashrc file to get this done. However, when I exit, the terminal colors are not reset to the local ones.

I solved the problem, but I am not sure if it is the best solution. This is what I could come up with.

On the ~/.bash_logout on the remote server, I put:

echo -e "\033[0m"
/usr/bin/clear

Just out of curiousity: Does anyone know of a better way? (I got the echo -e "\033[0m" line from http://edoceo.com/liber/linux-bash-shell)

share|improve this question
1  
I recommend you use tput to change colours instead. Look it up. –  Ram Jul 31 '11 at 16:14
    
What colors are you setting and how? Do you mean your prompt (PS1)? –  terdon Jan 5 at 11:15
add comment

1 Answer 1

If you put the colors you want in the remote account's ~/.bashrc it should take effect on login and revert to your local settings on exit.

share|improve this answer
    
I thought so too. But, they did not revert back when I exited ssh. Maybe it's because I was using setterm in .bashrc (using GNOME terminal). Do you use a different method of setting the color scheme in .bashrc? –  dgo.a Jul 31 '11 at 18:24
    
if you're using GNOME, I'm assuming you run linux. I use Ubuntu, but I'm guessing the process is pretty similar across the distros. You can backup the file then open it in a text editor and edit the contents starting at the line that says PS1=. You can find information at novell.com/coolsolutions/tools/17142.html. It tells you more than you ever wanted to know about the .bashrc file. –  Yitzchak Jul 31 '11 at 19:16
    
Uh, no. Terminal settings are not based on what you're doing in the terminal. They (anthromorphizing!) don't care if you're local, remote, working in Swahili or anything. It's a simple state machine. Since you used a command to change it to something... you have to use a command to change it to something else. The .bash_logout solution is the best way, unless you want to write an alias/function to wrap your ssh commands. Blech. Easier, make your settings (whatever they are) part of your PS1 prompt output. When you log into a machine, it'll change, log out, old prompt will reinstate. –  lornix Jul 27 '13 at 3:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.