Skip to content

Instantly share code, notes, and snippets.

@ernix
Created December 26, 2010 04:48
Show Gist options
  • Save ernix/755223 to your computer and use it in GitHub Desktop.
Save ernix/755223 to your computer and use it in GitHub Desktop.
Set OSX terminal window background color per SSH hosts.
#!/bin/sh
#--------------------------------------------------------------------#
# Set OSX terminal window background color per SSH hosts.
#--------------------------------------------------------------------#
change_bgcolor () {
case $1 in
red)
osascript -e 'tell app "Terminal" to set background color of first window to {17655, 0, 0, -16373}';;
winered)
osascript -e 'tell app "Terminal" to set background color of first window to {10000, 0, 0, -16373}';;
green)
osascript -e 'tell app "Terminal" to set background color of first window to {0, 17655, 0, -16373}';;
blue)
osascript -e 'tell app "Terminal" to set background color of first window to {0, 0, 17655, -16373}';;
*)
osascript -e 'tell app "Terminal" to set background color of first window to {0, 0, 0, -16373}';;
esac
}
case $1 in
*foo.com)
color=red;;
*bar.com)
color=winered;;
*)
color=blue;;
esac
change_bgcolor $color
trap 'change_bgcolor' EXIT
ssh $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment