Add command autocompletion to the interactive CLI
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 top> show -
p> show -<TAB>provides a menu of options -
p> show my<TAB>provides a menu of items returned bylocated my
Context
Autocompletion is vital for command line interfaces.
We support autocompletion already, you need to have readline installed.
https://github.com/keepassxreboot/keepassxc/blob/develop/src/cli/keepassxc-cli.cpp#L88
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
Did you compile keepassxc for yourself?
Nope. I tried both the Ubuntu PPA and AppImage. The USE_READLINE flag is not enabled by default, is it?
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.
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
Thanks!
I would appreciate this a lot. This is basically the ONE thing I miss from pass(1).
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.
PR hasn't been merged yet