Skip to content

Mac OS X Terminal: visual indication for your ssh connection

Here’s a HowTo for a nice visual indication to see quickly if your Mac OS X Terminal is running which ssh connection.

The trick is to change your Terminal Theme before you ssh and change it back afterwards.

1. Create Theme:
got to Terminal -> Preferences -> Settings create a new theme (or copy existing one) and adjust to your needs, e.g. a light red background etc. Give it a nice name e.g. “SSH-Theme”

2. Add this function to your .bashrc

function tabc() { NAME=$1; if [-z "$NAME"]; then NAME="Default"; fi osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\"" }

“Default” is my default Terminal theme, name this whatever u have

Usage:
tabc SSH-Theme #switch to theme with name tabc #switch to default theme

3. Create alias to ssh to server:

` alias sshmyserver=”tabc SSH-Theme; ssh yourserver.com; tabc”`

That’s it - your are done! Now, if you type sshmyserver, your Terminal color will change, ssh will start, and when you end ssh, everything will be back again..

Btw. for Terminal on Mac OS X, I very recommend Visor - a quake like console

UPDATE

That’s how you do it with iTerm:

` function tabc() { COLOR=$1; if [-z “$COLOR”]; then COLOR=”{0, 7722, 9941}”; fi osascript -e “tell application "iTerm" to set background color of current session of current terminal to $COLOR” }`

alias sshmyserver=”tabc ‘{18000, 2500, 2500}’; ssh yourserver.com; tabc”