3

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.

  • Starting with removing/disabling oh-my-zsh and see if it still happens is a good first step. – llua Jun 20 '15 at 0:28
  • Thanks, but that wasn't the problem. I've edited the question. – yong Jun 20 '15 at 0:44
  • This is (almost) totally unrelated to the point of your question (that's why I'm writing this as a comment and not an answer), but — I'm totally unfamiliar with zsh or oh-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 use program-name "$@" instead of program-name $* – G-Man Says 'Reinstate Monica' Jun 20 '15 at 0:51
4

Ok, I've found the solution: deleting all zcompdump files solved the problem:

rm ~/.zcompdump*
2

I ran the following and it fix the tab completion.

autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.