#!/bin/bash
#
# (1) copy to: ~/bin/ssh-colorize 
# (2) set:     alias ssh=~/bin/ssh-colorize
# (3) do:      chmod +x ~/bin/ssh-colorize
#
# Forkd from https://gist.github.com/thomd/956095

set_term_bgcolor(){
  local R=$1
  local G=$2
  local B=$3
  /usr/bin/osascript <<EOF
tell application "iTerm"
  tell the current window
    tell the current session
      set background color to {$(($R*65535/255)), $(($G*65535/255)), $(($B*65535/255))}
    end tell
  end tell
end tell
EOF
}

if [[ "$@" =~ ss-platform ]]; then
  set_term_bgcolor 40 0 0
elif [[ "$@" =~ ss-support ]]; then
  set_term_bgcolor 0 40 0
# add more host defs here.  can be hostnames or ~/.ssh/config entries
#
# include the following if you want to highlight *any* ssh session
else
  set_term_bgcolor 0 0 20
fi

ssh $@

set_term_bgcolor 0 0 0