keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
21.39k stars 1.48k forks source link

Added zsh completions #11441

Open fredricocalamari opened 2 weeks ago

fredricocalamari commented 2 weeks ago

Added zsh completion files. This feature allows zsh users to easily reference all options for keepassxc by typing into the zsh console: keepassxc-cli command --\<tab key> --option1 --Description of option1 --option2 --Description of option2 ...

I have included install.txt which contains instructions for end users and Linux distribution package maintaners on where it should be installed to.

Screenshots

image image image image image

Testing strategy

Place all of the _keepassxc* files (exclude install.txt) in the following folder: /usr/share/zsh/site-functions/

Set permissions: chmod 644 /usr/share/zsh/site-functions/_keepassxc*

Add the following lines to the file "~/.zshrc": autoload -Uz compinit compinit

Restart the terminal Type into console "keepassxc-cli\<space key>" then hit \<tab key> to see the commands for the program. Type in "keepassxc-cli edit -" then hit \<tab key> to see the option arguments for the command. It is possible to string options together, for example you can continue completing after "keepassxc-cli edit --key-file \<file> by typing "\<space key>-" and hitting \<tab key> again to see additional options. The first option (e.g. --key-file in this example) does not appear again in the new list that appears since it was already used.

Type of change

droidmonkey commented 2 weeks ago

Why do we need completions for keepassxc? If anything you should make them for keepassxc-cli

fredricocalamari commented 2 weeks ago

Why do we need completions for keepassxc? If anything you should make them for keepassxc-cli

You're right. I'll make completions for keepassxc-cli and resubmit. I finished the completions, however I need to fix a small bug that made zsh unexpectedly complete the commands for keepassxc-cli when not invoking keepassxc-cli. For example, typing in "ls \<space>\<tab key>" in zsh was invoking the _keepassxc-cli_ls function with compinit. Obviously, that's not ideal. I'll fix it shortly and resubmit for review.