Change Terminal Background Color When ssh’ed – Mac

Save this as “ssh” somewhere on your $PATH ahead of /usr/bin/ssh and make it executable

#!/bin/sh

HOSTNAME=$(echo $@ | sed 's/.*@//')

set_theme () {
    osascript -e "tell application \"Terminal\" to set current settings of first window to settings set \"$1\""
}

on_exit () {
    set_theme "Solarized Light"
}

trap on_exit EXIT

case $HOSTNAME in
  # These all do the same thing but we could have different themes for different locations
  hb|pd|decksite) set_theme "Solarized Dark" ;;
  *) set_theme "Solarized Dark" ;;
esac

/usr/bin/ssh "$@"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.