Skip to content

Instantly share code, notes, and snippets.

@henrytseng
Last active October 11, 2018 01:34
Show Gist options
  • Save henrytseng/f58ec119d5d989a6306d769d212b7648 to your computer and use it in GitHub Desktop.
Save henrytseng/f58ec119d5d989a6306d769d212b7648 to your computer and use it in GitHub Desktop.
# Color the OSX Terminal app according the hostname used in ssh
# Assumes you log in with a simple "ssh myuserid@remotehost"
# Read the following posts, which gave me the inspiration/knowledge:
# http://toolsmiths.blogspot.com/2010/04/how-to-change-your-osx-terminal-color.html
# http://www.ict4g.net/adolfo/notes/2014/07/16/change-osx-terminal-settings-from-command-line.html
# Two themes I am going to be toggling back and forth
LOCAL="Homebrew"
REMOTE="Ocean"
# Change the color of the terminal to the remote configuration
LS="Application(\"Terminal\").windows[0].currentSettings = Application(\"Terminal\").settingsSets[\"$REMOTE\"]"
osascript -l JavaScript -e "$LS" > /dev/null
# Do the normal ssh passing all original parameters to `ssh`
/usr/bin/ssh "$@"
# Change the color of the terminal back to what it was before
RS="Application(\"Terminal\").windows[0].currentSettings = Application(\"Terminal\").settingsSets[\"$LOCAL\"]"
osascript -l JavaScript -e "$RS" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment