Skip to content

Instantly share code, notes, and snippets.

@chales
Forked from ernix/vsh.sh
Last active May 8, 2016 17:27
Show Gist options
  • Save chales/36e169c24b42d9732206 to your computer and use it in GitHub Desktop.
Save chales/36e169c24b42d9732206 to your computer and use it in GitHub Desktop.
Terminal color switcher.
#!/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