Created
October 8, 2013 06:59
-
-
Save igmar/6880672 to your computer and use it in GitHub Desktop.
SSH colored backgrounds
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/sh | |
if [ "$(tty)" == 'not a tty' ] || [ $TERM_PROGRAM != "iTerm.app" ]; then | |
exec ssh "$@" | |
exit $? | |
fi | |
if [ $# -eq 0 ]; then | |
exec ssh "$@" | |
fi | |
set_term_bgcolor(){ | |
local R=$1 | |
local G=$2 | |
local B=$3 | |
/usr/bin/osascript <<EOF | |
tell application "iTerm" | |
tell the current terminal | |
tell the current session | |
set background color to {$(($R*65535/255)), $(($G*65535/255)), $(($B*65535/255))} | |
end tell | |
end tell | |
end tell | |
EOF | |
} | |
# | |
while read -r hostname r g b; do | |
[[ $hostname = \#* ]] && continue | |
if [[ "$@" =~ "$hostname" ]]; then | |
break | |
fi | |
done < "$HOME/.ssh/hosts_rgb" | |
set_term_bgcolor $r $g $b | |
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