Previously I have been using this handy script with oh-my-zsh
to set the tab color whenever I ssh into a machine:
# iTerm2 window/tab color commands
# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes
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"
}
tab-reset() {
echo -ne "\033]6;1;bg;*;default\a"
trap - INT EXIT
}
# Change the color of the tab when using SSH
# reset the color after the connection closes
color-ssh() {
if [[ -n "$ITERM_SESSION_ID" ]]; then
trap "tab-reset" INT EXIT
if [[ "$*" =~ "production|ec2-.*compute-1" ]]; then
tab-color 255 0 0
else
tab-color 144 181 80 #0 255 0
fi
fi
ssh $*
}
compdef _ssh color-ssh=ssh
alias ssh=color-ssh
However, today I have discovered that the autocomplete is now broken! My ssh
no longer autocompletes if I run this script. How do I diagnose what is going on?
Edit:
Disabling oh-my-zsh
and sourcing the file leads to the error: command not found: compdef
.
oh-my-zsh
and see if it still happens is a good first step.zsh
oroh-my-zsh
. Are they POSIX compliant? Because, in any POSIX-compliant shell, if a function wraps a program, and invokes that program with all of the arguments that were passed to the function, it should useprogram-name
"$@"
instead ofprogram-name
$*