Skip to content

Instantly share code, notes, and snippets.

@igmar
Created October 8, 2013 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igmar/6880672 to your computer and use it in GitHub Desktop.
Save igmar/6880672 to your computer and use it in GitHub Desktop.
SSH colored backgrounds
#!/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