Skip to content

Instantly share code, notes, and snippets.

@miharekar
Last active December 9, 2020 08:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miharekar/c6072e4fede3a6fe0f6b to your computer and use it in GitHub Desktop.
Save miharekar/c6072e4fede3a6fe0f6b to your computer and use it in GitHub Desktop.
Don't Screw Up When You SSH To Production
if [[ -n "$ITERM_SESSION_ID" ]]; then
function change-tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
echo -ne "\033]6;1;bg;blue;brightness;$3\a"
}
function change-profile() {
echo -ne "\033]50;SetProfile=$1\a"
}
function reset-colors() {
echo -ne "\033]6;1;bg;*;Default\a"
change-profile Default
}
function colorssh() {
if [[ "$1" =~ "^ssh " ]]; then
if [[ "$*" =~ "web*|production|ec2-.*compute-1" ]]; then
change-profile SSH
change-tab-color 255 0 0
fi
else
reset-colors
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd reset-colors
add-zsh-hook preexec colorssh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment