23 Aug 2019 , tagged: zsh, Go, Golang
zsh Autocompletion Caveat
I spent a good hour trying to get a custom completion script working while porting my app Harbormaster to Cobra. It would and would not work. I retried writing the file, restarting the shell and it would just not offer any completions.
Eventually I stumbled upon a innocent looking post on Github that held the solution: remove the .zcompdump file which holds the cached completions. So I ran rm ~/.zcompdump && compinit
and everything works as expected.
For future reference, I found this post on zsh completions very helpful. Also, zsh completions can either be sourced dynamically (currently not working in zsh but is coming, until then the completion should be added to a file in the $fpath
:
$ harbormaster completion zsh > ~/.zsh/completion/_harbormaster
You might have to run compinit
or restart your shell.