Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added zsh completions #11441

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

fredricocalamari
Copy link

@fredricocalamari fredricocalamari commented Nov 6, 2024

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

  • ✅ New feature (change that adds functionality)
  • ✅ Documentation (non-code change)

@droidmonkey
Copy link
Member

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

@droidmonkey droidmonkey marked this pull request as draft November 6, 2024 11:25
@fredricocalamari
Copy link
Author

fredricocalamari commented Nov 6, 2024

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.

@fredricocalamari fredricocalamari marked this pull request as ready for review November 7, 2024 11:15
@fredricocalamari fredricocalamari marked this pull request as draft November 7, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants