keepassxc icon indicating copy to clipboard operation
keepassxc copied to clipboard

Add command autocompletion to the interactive CLI

Open cizmazia opened this issue 5 years ago • 10 comments

Summary

Provide bash/zsh-like completion in the interactive CLI

Examples

Open the interactive CLI.

keepassxc cli open ~/p.kdbx
p>

Use the TAB key to complete words. A menu shall be displayed when there are multiple options.

  • p> sh<TAB> completes to p> show
  • p> show -<TAB> provides a menu of options
  • p> show my<TAB> provides a menu of items returned by located my

Context

Autocompletion is vital for command line interfaces.

cizmazia avatar Apr 30 '20 04:04 cizmazia

We support autocompletion already, you need to have readline installed.

https://github.com/keepassxreboot/keepassxc/blob/develop/src/cli/keepassxc-cli.cpp#L88

droidmonkey avatar Apr 30 '20 14:04 droidmonkey

Thanks for your response. That's good news! Please could you give me any pointers on troubleshooting this? It seems that I already have readline installed:

$ keepassxc-cli -v
2.5.4
$ dpkg -l | grep readline
ii  libreadline-dev:amd64                 6.3-8ubuntu2                                    amd64        GNU readline and history libraries, development files
ii  libreadline5:amd64                    5.2+dfsg-3build1                                amd64        GNU readline and history libraries, run-time libraries
ii  libreadline5-dbg                      5.2+dfsg-3build1                                amd64        GNU readline and history libraries, debugging libraries
ii  libreadline6:amd64                    6.3-8ubuntu2                                    amd64        GNU readline and history libraries, run-time libraries
ii  libreadline6-dev:amd64                6.3-8ubuntu2                                    amd64        GNU readline and history libraries, development files
ii  libterm-readline-gnu-perl             1.28-2build1                                    amd64        Perl extension for the GNU ReadLine/History Library
ii  readline-common                       6.3-8ubuntu2                                    all          GNU readline and history libraries, common files

cizmazia avatar Apr 30 '20 17:04 cizmazia

Did you compile keepassxc for yourself?

droidmonkey avatar May 04 '20 11:05 droidmonkey

Nope. I tried both the Ubuntu PPA and AppImage. The USE_READLINE flag is not enabled by default, is it?

cizmazia avatar May 04 '20 18:05 cizmazia

You know what I just realized we never hooked up a completer to our readline use so it will not complete commands! This needs to be done.

droidmonkey avatar May 04 '20 19:05 droidmonkey

We should actually use linenoise-ng instead of readline library. We can embed it directly into our code base, very small footprint.

https://github.com/arangodb/linenoise-ng

droidmonkey avatar May 04 '20 19:05 droidmonkey

Thanks!

cizmazia avatar May 04 '20 20:05 cizmazia

I would appreciate this a lot. This is basically the ONE thing I miss from pass(1).

adamemerson avatar Feb 21 '21 07:02 adamemerson

Hi,

is this supposed to be implemented?

I have version 2.7.10 and … well, it does kind of autocomplete, but it autocompletes on files in the current directory and not on the commands or on the path of groups and sub-groups, which is not useful for any common task.

I.

iridos avatar Nov 18 '25 14:11 iridos

PR hasn't been merged yet

droidmonkey avatar Nov 19 '25 01:11 droidmonkey