OK, if you insist on invoking ssh from the command line, here's something that should do the trick: write a shell script and save it somewhere as colorssh.sh
. When it runs, it looks at its arguments for a matching host and sets the active terminal window's colors appropriately. Then it invokes the real ssh, passing along those arguments. When ssh returns execution to the script, it sets the colors back to normal.
Since you probably want to keep typing ssh
instead of colorssh.sh
, you can set an alias in your .profile
.
As for the script itself? Here is teh codez:
#!/bin/bash
function setTerminalColors {
osascript \
-e "tell application \"Terminal\"" \
-e "tell selected tab of front window" \
-e "set normal text color to $1" \
-e "set background color to $2" \
-e "end tell" \
-e "end tell"
}
for ARG in $*
do
case "$ARG" in
host.example.com)
[email protected])
setTerminalColors "{0,65535,65535}" "{65535,0,0}"
;;
[email protected])
setTerminalColors "{65535,65535,0}" "{0,65535,0}"
;;
esac
done
ssh $*
# back to normal
setTerminalColors "{0,0,0}" "{65535,65535,65535}"
You'll have to edit the script to add new host/color combinations.
Note that colors must be specified as an RGB triplet of integers in the range 0-65535. I know, weird, right?
Technically, the AppleScript portion changing deprecated properties. You're supposed to change a window's colors via its "settings set" property, but I suspect that would change all windows using that settings set, not just the current one.
Also, this script assumes that black on white is your "normal" setting. If that's not the case you could change the script to save the current values before running or use the colors from the default settings set.