Change your terminal theme when you ssh into a server

I am in a tough spot. I am a technician, but I also am a design whore, so when I had to find a solution to one common problem (forgetting that your terminal tab is not on localhost), I couldn’t just solve the problem, but I had to find a good looking solution to that.

A #lazytweet only partially helped me, directing me to this useful post. I liked the approach, it was close, but not there.

I played with shell functions for a bit and came up with this:

The way it works is simple, it tells terminal to change it’s theme before ssh-ing and changes it back when ssh quits.

You might be wondering what Solarized Dark and Light are. It’s quite simple, they are two flavors of the best theme ever made.

If you’re still reading, a shameless plug: use my version of git-prompt for the best command prompt ever made :)

6 Responses to “Change your terminal theme when you ssh into a server”

  1. Dan Ring Says:

    Thanks, this is a perfect complement to the Solarized themes. A very thoughtful way to quickly identify which terminals are remote or not!

  2. Bruno Says:

    what if i only want the tab i am ssh’ing from to be different?
    I tried to look around but couldn’t find anyway of doing it..

    ps. and this script as is isn’t working for me either, the applescript doesn’t have any effect :(

  3. Giovanni Intini Says:

    This works only on the active tab, the other tabs remain of their original color. Where are you putting the bash function?

  4. Bruno Says:

    finally had time to look into it again. the problem was some sort of conflict with Visor, which i was getting more and more bored of so it got booted :)

    now the challenge is to make it work with a different color (theme) depending on where you ssh into (via .ssh/config hosts)... any hints?

  5. Giovanni Intini Says:

    Bruno, I have a more complex version (that fix a bug in the applescript) and allows you to parse .ssh/config, but I think it’s overkill, do you want me to share it?

  6. Bruno Says:

    I would be curious to see what it looks like :)