bat-extras icon indicating copy to clipboard operation
bat-extras copied to clipboard

batman completion

Open christ4k opened this issue 1 year ago • 5 comments

When running batman there is no completion upon tab tapping. Is there a way to "link" man autocompletion with batman?

christ4k avatar May 22 '24 09:05 christ4k

It would depend on your shell. I'm not sure about completions for bash and zsh, but for fish it is:

complete batman --wraps man

eth-p avatar Jun 01 '24 22:06 eth-p

After a little search, I think I made it out with bash

I found something relative here and here

And I added into .bashrc the following line.

complete -f _longopt batman

I use zsh alongside with bash. I think I did not find the right way to make the same thing on zsh. If someone can tell if the above solution is right, and if someone could tell the "solution" for zsh would be nice!

christ4k avatar Jun 02 '24 11:06 christ4k

for those using bash, _comp_cmd_man (the completion function for man included in scop/bash-completion) can be reused for batman:

  • look for the completion script for man, usually /usr/share/bash-completion/completions/man if bash-completion is installed on your system, or download the script from here
  • copy that to a new completion script, preferably named batman, with the complete -F _comp_cmd_man line modified for batman
  • put the new script in ${BASH_COMPLETION_USER_DIR:-$XDG_DATA_HOME/bash-completion}/completions/ for lazy load, or source the script / paste the content of the script to either ~/.bash_completion or ~/.bashrc (see the answer to Where should I install my own local completions?)

minhtrancccp avatar Jul 19 '24 22:07 minhtrancccp

@christ4k have you found the way to do it for zsh?

niksingh710 avatar Aug 08 '24 07:08 niksingh710

@christ4k have you found the way to do it for zsh?

Not sure if this is again the right way to do it. I followed this and I think I have the basic functionality of autocomplete with batman.

compdef _command batman

I put this line above in my .zshrc file

christ4k avatar Oct 04 '24 05:10 christ4k