gopass icon indicating copy to clipboard operation
gopass copied to clipboard

No zsh completion for "gopass generate" and too many results

Open ibot3 opened this issue 4 years ago • 6 comments

Summary

The zsh completion for the gopass generate command is not working for me.

I am also unhappy with the completion as it currently is, because even if it is working, it shows all possible password files in the path which leads to many autocomplete results. A behavior like the "normal" file autocompletion (f.e. of ls) would be far more convenient. At least an option for this would be nice.

Steps To Reproduce

  • Enter gopass generate and press Tab.

Expected behavior

  • Folder completion for gopass generate
  • Opttionally: Do not show completion results recursively

Environment

  • gopass 1.9.2 (2020-05-13 21:14:02) go1.14.2 linux amd64
  • 5.6.13-arch1-1
  • oh-my-zsh

ibot3 avatar May 18 '20 10:05 ibot3

Yes, I agree. Autocompletion should only suggest the next level. I thought we did fix that in the past ...

dominikschulz avatar May 18 '20 11:05 dominikschulz

➜ ./gopass foo<TAB>
foo.com/potato  foo/apple                foo/orange            foo/bar/baz             foo/bar/quux


➜ git log -1 --format='%H'
88e589a1d67260f3aff6ba4ffcafdf709d3ba6d9


➜ ./gopass version
gopass 1.9.0-git+HEAD go1.14.2 linux amd64
<root>     - gpg 2.2.20 - git 2.26.2 -   fs 0.1.0
Available Crypto Backends: age, gpgcli, plain, xc
Available RCS Backends: gitcli, noop
Available Storage Backends: fs, inmem


➜ uname -srm
Linux 5.6.13-arch1-1 x86_64

Just chiming in -- I don't appear to have this same issue.

sudoforge avatar May 20 '20 00:05 sudoforge

(The above works the same for subcommands, e.g. ./gopass generate foo<TAB>)

sudoforge avatar May 20 '20 00:05 sudoforge

Hmm, I think for the first level it should not suggest foo/bar/baz, or should it?

dominikschulz avatar May 20 '20 16:05 dominikschulz

If the intent is to only show the first level after the pattern, then it's bugged (although I'm unclear on whether or not this matches with what the issue author is describing -- it kind of sounds like they're experiencing "all" of the entries being suggested).

I personally think that showing all sub-levels is appropriate, but I can see the argument for only showing the first sub-level (matching what other CLIs do, e.g. ls); especially when a user has many sub-levels or entries within different sub-levels.

sudoforge avatar May 20 '20 16:05 sudoforge

I'm afraid I'm probably partially responsible for the current behaviour, since I introduced the --folders argument to gopass to be able to generate such completions.

The current behaviour is based on this snippet: https://github.com/gopasspw/gopass/blob/09c9031fb4bf52ebeda7a41d2862121785253e7f/internal/completion/zsh/template.go#L55-L59

This is zsh completion system being simply fed the output of the gopass ls --folders command basically.

Now, the generate (and insert) keywords are relying on both the ``
Here is the current behaviour:

$> gopass generate foo<TAB>
 -- folders --
foo      foo/foo  foo/zen
 -- passwords --
foo/foo/bar  foo/zen/bar

I understand you would prefer to have only one level of completion at once, and I agree it might be cleaner... However I'm afraid I'm not a specialist of Zsh completion system and so I wanted to test achieving this goal using the gopass ls --folder --l 1 command but it seems the -l 1 flag is definitively not doing what I thought it should.

I'll look into it and might push some more unit tests for gopass ls to debug the --limit flag.

AnomalRoil avatar Jul 17 '20 15:07 AnomalRoil

Should have been fixed long ago, I think?!

dominikschulz avatar Dec 04 '22 13:12 dominikschulz