Skip to content

Instantly share code, notes, and snippets.

@chrishein
Created June 14, 2013 22:39
Show Gist options
  • Save chrishein/5785835 to your computer and use it in GitHub Desktop.
Save chrishein/5785835 to your computer and use it in GitHub Desktop.
Change Terminal.app Profile when connecting through ssh according to server
#!/bin/sh
# Place this script in your path before /usr/local/bin . Make it executable
# If using .ssh/config to define username. "ssh server1"
HOSTNAME=$@
# If connecting using "ssh user1@server1"
# HOSTNAME=`echo $@ | sed s/.*@//`
function setTerm() { PROFILE=${1}; echo "tell app \"Terminal\" to set current settings of first window to settings set \"${PROFILE}\""|osascript; };
on_exit () {
setTerm "Basic"
}
# Uncomment to go back to default (Basic) after disconnecting
# trap on_exit EXIT
case $HOSTNAME in
server1|server2) setTerm "Grass" ;;
server3) setTerm "Homebrew" ;;
server4) setTerm "Man Page" ;;
server5) setTerm "Novel" ;;
*) ;;
esac
/usr/bin/ssh "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment