Last active
August 17, 2016 07:42
-
-
Save seamountain/b0488de896ac68810a40b238cd5d7c99 to your computer and use it in GitHub Desktop.
set the background color of iTerm based on ssh-host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# (1) copy to: ~/bin/ssh-host-color | |
# (2) set: alias ssh=~/bin/ssh-host-color | |
# | |
# Inspired from http://talkfast.org/2011/01/10/ssh-host-color | |
# Fork from https://gist.github.com/773849 | |
# | |
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 [[ "$@" =~ thomd ]]; then | |
set_term_bgcolor 69 13 13 # production env color (red) | |
elif [[ "$@" =~ git ]]; then | |
set_term_bgcolor 122 30 42 # sandbox env color (dark blue) | |
fi | |
ssh $@ | |
set_term_bgcolor 0 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment