bat-extras
bat-extras copied to clipboard
ZSH autocompletion support
Would it be possible to add ZSH autocompletion to the commands? It would be very useful, especially to autocomplete man pages.
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 :)
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.
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.