Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So you want to change terminal colors and resetting them back on exit? It's possible!

Thanks to .ssh/config, alias and setterm.

share|improve this question
    
I know, we have tons of such questions, but I just did not found any simple as my current version. Also to those, who can expand my answer with details, pls expand it. Then after more detailed version we can accept it. – gaRex Jun 5 '13 at 8:13

.bash_aliases

function ssh_alias() {
    ssh $@;
    setterm -default -clear rest;
}

alias ssh=ssh_alias

/etc/ssh/ssh_config

# Make sure you have this line there:
PermitLocalCommand yes

.ssh/config

Host your.production.host
  User root
  LocalCommand setterm -term linux -back red -fore white -clear rest

Now you can in bash:

some command
# all in default colors
ssh your.production.host
# colors changed
# ....
exit
# colors changed back! yeea!
share|improve this answer
    
This is exactly what I was looking for after googling it for hours. – MonkeyMonkey Nov 5 '14 at 16:54
    
Finally, after hours of search, I found exactly what I wanted. Thank you gaRex :) – Amal Murali Jun 14 at 14:12

(read gaRex's response first)

setterm has changed the arguments in recent versions:

.bash_aliases

function ssh_alias() {
    ssh $@;
    setterm --default --clear all;
}

alias ssh=ssh_alias

.ssh/config

Host myproject.pro
    HostName myproject.com
    User root
    IdentityFile ~/.ssh/myproject
    LocalCommand setterm --term linux --background white --foreground black --clear all

You can still use:

--clear rest

You can reload .bash_aliases file with:

exec bash

More info:

man setterm
share|improve this answer
    
This is a 3 year old question and your answer is similar to the one already answered – SeanClt Mar 26 at 20:52
1  
yep... I only wanted to add more info. Could be a response to gaRex's response. – JoniJnm Mar 26 at 21:58
    
yep i am with and clearly understand you want to help and we want folks like you – SeanClt Mar 26 at 21:59
    
click on "improve this answer" in my initial answer. – gaRex Jun 15 at 6:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .