I use zsh -d -f to start zsh without an rc.
โฏ zsh -d -f
bianca2% source <(gopass completion zsh)
_gopass:213: command not found: _describe
_gopass:214: command not found: _arguments
_gopass_complete_passwords:1: command not found: _arguments
_gopass_complete_passwords:3: command not found: _values
Actually, this is the wrong error, I'm getting something different in my host terminal.
bianca2% autoload -Uz compinit
compinit
bianca2% source <(gopass completion zsh)
_tags:comptags:36: can only be called from completion function
_tags:comptry:55: can only be called from completion function
_tags:comptags:60: can only be called from completion function
_tags:comptags:67: can only be called from completion function
_arguments:comparguments:319: can only be called from completion function
_arguments:comparguments:319: can only be called from completion function
_values:compvalues:11: can only be called from completion function
Hi, I'm afraid but I'd need help from someone familiar with zsh to resolve this issue.
This seems to work if I do gopass completion zsh > ~/newdir/_gopass.zsh and then add fpath=(~/newdir $fpath) to my .zshrc.
Reading some issues, I suspect the intention was that the completion would be a build artifact that ended up at /usr/lib/gopass/_gopass.zsh or something.
https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org might be worth reading, but I'm not certain.
Naturally, I think I found the dynamic solution straight after I posted that. compdef _gopass gopass hooks it up. Resulting lines in .zshrc:
source <(gopass completion zsh | head -n -1 | tail -n +2)
compdef _gopass gopass
The head/tail drop the "broken" lines. I think the compdef should be added to the output of gopass completion zsh. If I use source <((gopass completion zsh | head -n -1 | tail -n +2); echo 'compdef _gopass gopass') to append the compdef to the output, this also works.
Thanks for investigating! I'm still not exactly sure what the fix should look like. Would be amazing if someone using zsh could create a PR. Otherwise I'll need some time to have a look at the zsh docs and see what I can do, but this may take a few days.
@dominikschulz I think you need to remove the #compdef gopass from the generated output, and remove the bottom line _gopass.
Then add compdef _gopass gopass to the bottom of the file.
Not sure if that breaks the changes we tried to do in #565. WDYT @Foxboron ?
Sourcing gopass completion zsh is the wrong approach to get zsh completions. The file needs to enter a compinit directory, and zsh will handle it. If there is documentation that is needed to resolve the confusion I'll fix it.
Yes, the suggested changes will break the completion.
I don't know the given distro/OS. But if the completion is not package properly the solution is gopass completion zsh > /usr/share/zsh/site-functions/_gopass.
Then you remove ~/.zcompdump and reload compinit.
I don't know the given distro/OS. But if the completion is not package properly the solution is gopass completion zsh > /usr/share/zsh/site-functions/_gopass.
The documentation doesn't indicate this, and says to source from the output of that.
@SevereOverfl0w I'll look over the documentation try explain the situation better. Thanks
I've just hit this installing the rpm in centos. completion is not working. not sure what to do.
this hack worked by @SevereOverfl0w for me:
source <(gopass completion zsh | head -n -1 | tail -n +2)
compdef _gopass gopass
@Foxboron, how do you actually restart compinit? I have a _gopass file in that dir, but not sure how to proceed in relation to compinit.
rm the .zcompdump file in home then autoload -U compinit && compinit.
If your distribution doesn't include completion create a bug report to them.
The whole purpose of @Foxboron's change, is that attempting to source the completion definition is a completely broken way to handle zsh completion and should not be done. zsh has an excellent completion system that works properly, as long as you actually use it.
Given that one of the major touted benefits of zsh is the completion system, any zsh installation that does not even use it is, well, broken.
The properly-written zsh completion for gopass is meant to be installed in the zsh completions directory, as defined by either the OS-level /usr/share/zsh/site-functions/, or the user-specified fpath. If gopass is installed via a package manager to usr/ then this should Just Workโข, if it is installed to the user's home directory in ~/bin or wherever, then the completion file should likewise be generated and stored in $fpath.
The result is that zsh can automatically detect the completion, and load it when necessary, similar to how bash completions are stored in a global completions directory and automatically lazy-loaded when the command is tab-completed for the first time.
No user action or configuration in any way shape or form is required, other than making sure that the generic completion system is hooked up. This is, after all, far more convenient than requiring every single user-installed program to inject itself into the user's shell rc files.
Again, this is the recommended and intended way that zsh completions are meant to be done. The fact that people were sourceing anything ever, was a bug that has been fixed.
@Foxboron @eli-schwartz, I just tried the procedure on an updated arch linux now.
/usr/share/zsh/site-functions has the _gopass file properly installed in my system. I did nothing, just pacman -S gopass and the file is already there.
however, after deleting ~/.zcompdump and issuing autoload -U compinit && compinit and restarting my shell, gopass does not have completions. Is this something on my end or in archlinux?
here is the result of print -l $fpath:
/usr/local/share/zsh/site-functions
/usr/share/zsh/site-functions
/usr/share/zsh/functions/Calendar
/usr/share/zsh/functions/Chpwd
/usr/share/zsh/functions/Completion
/usr/share/zsh/functions/Completion/Base
/usr/share/zsh/functions/Completion/Linux
/usr/share/zsh/functions/Completion/Unix
/usr/share/zsh/functions/Completion/X
/usr/share/zsh/functions/Completion/Zsh
/usr/share/zsh/functions/Exceptions
/usr/share/zsh/functions/Math
/usr/share/zsh/functions/MIME
/usr/share/zsh/functions/Misc
/usr/share/zsh/functions/Newuser
/usr/share/zsh/functions/Prompts
/usr/share/zsh/functions/TCP
/usr/share/zsh/functions/VCS_Info
/usr/share/zsh/functions/VCS_Info/Backends
/usr/share/zsh/functions/Zftp
/usr/share/zsh/functions/Zle
/home/ninrod/.dotfiles/deps/zsh/ninrod/docker-compose-zsh-completion/src
/home/ninrod/.dotfiles/deps/zsh/ninrod/docker-zsh-completion/src
/home/ninrod/.dotfiles/deps/zsh/ninrod/pass-zsh-completion/src
/home/ninrod/.dotfiles/deps/zsh/zsh-users/zsh-completions/src
here are my full zsh dotfiles: https://github.com/ninrod/dotfiles/tree/master/zsh
@ninrod Works for me so unsure, make sure all .zcompdump files are deleted. If it still doesn't work it's better to submit a bug to our tracker then using the upstream tracker.
@Foxboron it worked allright for me. the issue was that I was using gopass 1.6.6. upgrading to 1.6.7 did the trick.
This worked for me on mac os.
print -l $fpath | grep '.oh-my-zsh/completions'
mkdir ~/.oh-my-zsh/completions
gopass completion zsh > ~/.oh-my-zsh/completions/_gopass
rm ~/.zcompdump*
having the same problem after upgrading my system (arch linux) I'd assume some zsh update issue?
It depends on if the arch linux package has been updated to respect the newly generated files.
In debian package file _gopass (probably generated from gopass completion zsh) should be placed to /usr/local/share/zsh/site-functions.
Current workaround for me:
gopass completion zsh | sudo tee /usr/local/share/zsh/site-functions/_gopass
The biggest problem I can see coming with this, is the update process when using go get directly to update Gopass, since then if there are new commands or so, the zsh completion file must be manually updated. But then it must be done with write access to the completion folder...
Maybe the simplest way around it could be to instruct people to add this in their .zshrc:
fpath=( ${GOPATH}/src/github.com/justwatchcom/gopass/completions "${fpath[@]}" )
so it would add the folder completions in the Gopass repo as a way to provide completion and then you could have a Travis after_success callback so that the file gopass/completions/_gopass would be automatically created using gopass completion zsh when Travis succeeds.
However I do not know whether it is considered bad practice or not to tell people to add a folder to their fpath.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm getting a similar, possibly related issue. If I press any key, then space (for completion), it prints something like this:
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
_tags:36: command not found: comptags
_tags:55: command not found: comptry
_tags:60: command not found: comptags
_tags:67: command not found: comptags
Most helpful comment
This worked for me on mac os.