Dr Nic, For me, it was gcp sdk's auto completion that breaks the above stack overflow post instructions. I added the following to my .zshrc *before* gcp's auto completion loads:
_cf-cli() { # All arguments except the first one args=("${COMP_WORDS[@]:1:$COMP_CWORD}") # Only split on newlines local IFS=$'\n' # Call completion (note that the first element of COMP_WORDS is # the executable itself) COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}")) return 0 } autoload -U +X compinit && compinit autoload -U +X bashcompinit && bashcompinit function compinit() {} function bashcompinit() {} complete -F _cf-cli cf
Which let both the gcloud and the cf work. The lines in gcp's sdk file that break things are: autoload -Uz compinit bashcompinit compinit bashcompinit
I did my cf code first and then redefine compinit / bashcomptinit to no-ops since I already loaded them. I'm sure there are more elegant solutions, but I don't want to fiddle with the gcloud distributed file google-cloud-sdk/completion.zsh.inc.