Skip to content

Instantly share code, notes, and snippets.

@hatarist
Last active December 31, 2015 17:39
Show Gist options
  • Save hatarist/8022085 to your computer and use it in GitHub Desktop.
Save hatarist/8022085 to your computer and use it in GitHub Desktop.
(zsh) Colorize iTerm2 prompt when connecting to SSH servers
alias sww="iterm_bg_color 30 0 0; ssh web-production; iterm_bg_color 0 0 0"
alias swt="iterm_bg_color 0 20 20; ssh web-test; iterm_bg_color 0 0 0"
function iterm_bg_color() {
local tty=$(tty)
osascript -e "
tell application \"iTerm\"
repeat with theTerminal in terminals
tell theTerminal
try
tell session id \"$tty\"
set background color to {(($1 * 257)), (($2 * 257)), (($3 * 257))} as RGB color
end tell
on error errmesg number errn
end try
end tell
end repeat
end tell"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment