Last active
March 31, 2017 23:27
-
-
Save treyd/92f57d04c9965eca545460a2345a85cf 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-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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment