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

ZSH autocompletion support #84

Open
Haltarys opened this issue Jan 4, 2023 · 3 comments
Open

ZSH autocompletion support #84

Haltarys opened this issue Jan 4, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Haltarys
Copy link

Haltarys commented Jan 4, 2023

Would it be possible to add ZSH autocompletion to the commands? It would be very useful, especially to autocomplete man pages.

@eth-p
Copy link
Owner

eth-p commented Mar 21, 2023

I would love to, but I don't really have experience with zsh or creating autocompletion definitions for it. I might take a shot at trying to create some in the future when time permits, but in the meantime, if anybody else knows how to and is willing to create them, I would be happy to accept them in a PR :)

@eth-p eth-p added enhancement New feature or request good first issue Good for newcomers labels Mar 21, 2023
@Haltarys
Copy link
Author

Haltarys commented Mar 21, 2023

Hello, I found a workaround to complete man pages for the batman command. This applies the _man completion function to the batman command (which ZSH or Oh My ZSH already apply by default to the man command):

# alias `man` to `batman` (this is optional)
command -v batman >/dev/null && alias man='batman'

# batman command completion (must be after sourcing Oh My Zsh: `source $ZSH/oh-my-zsh.sh`)
command -v batman >/dev/null && compdef _man batman

The command -v batman >/dev/null && bit ensures that the batman command exists before applying the patches.
It doesn't solve the issue for all the bat-extras utilities, but this was the most annoying one for me.

@eth-p
Copy link
Owner

eth-p commented Mar 24, 2023

On my MacOS machine, I managed to get it working with

autoload -U +X compinit && compinit
compdef batman=man

While I'd like to do proper completions for the other commands at some point, compdef batman=man will suffice for now. I'll add that as a vendor completion later this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants