gopass: Command not found for zsh completion
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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (11 by maintainers)
Commits related to this issue
- Clarifying the zsh documentation (#1525) Fixes #585 Fixes #1424 RELEASE_NOTES=[DOCUMENTATION] Improve documentation of Zsh completion setup Signed-off-by: Yolan Romailler <yolan@romailler.ch> — committed to gopasspw/gopass by AnomalRoil 4 years ago
- Clarifying the zsh documentation (#1525) Fixes #585 Fixes #1424 RELEASE_NOTES=[DOCUMENTATION] Improve documentation of Zsh completion setup Signed-off-by: Yolan Romailler <yolan@romailler.ch> — committed to kpitt/gopass by AnomalRoil 4 years ago
This worked for me on mac os.
Naturally, I think I found the dynamic solution straight after I posted that.
compdef _gopass gopass
hooks it up. Resulting lines in .zshrc:The head/tail drop the “broken” lines. I think the
compdef
should be added to the output ofgopass completion zsh
. If I usesource <((gopass completion zsh | head -n -1 | tail -n +2); echo 'compdef _gopass gopass')
to append the compdef to the output, this also works.Actually, this is the wrong error, I’m getting something different in my host terminal.
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.In debian package file
_gopass
(probably generated fromgopass completion zsh
) should be placed to/usr/local/share/zsh/site-functions
.Current workaround for me:
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-specifiedfpath
. 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
source
ing anything ever, was a bug that has been fixed.This seems to work if I do
gopass completion zsh > ~/newdir/_gopass.zsh
and then addfpath=(~/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.
I’m getting a similar, possibly related issue. If I press any key, then space (for completion), it prints something like this:
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
:so it would add the folder
completions
in the Gopass repo as a way to provide completion and then you could have a Travisafter_success
callback so that the filegopass/completions/_gopass
would be automatically created usinggopass 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.
@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.
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.