bat icon indicating copy to clipboard operation
bat copied to clipboard

output shell completion script by `bat --completion <shell>` command

Open tigerinus opened this issue 2 years ago • 4 comments

Currently the autocompletion script comes only with the source.

A better approach, would be something like bat --completion=bash.

Here is my current bash_completion script executed at login:

source <($HOME/.local/bin/helm completion bash)
source <($HOME/.local/bin/kustomize completion bash)
source <($HOME/.local/bin/pip completion --bash)
source <($HOME/.local/bin/stern --completion=bash)
source <($HOME/.local/node/bin/npm completion)
source $HOME/.local/bat/autocomplete/bat.bash # this can become `bat --completion=bash` 

tigerinus avatar Feb 02 '22 15:02 tigerinus

The bash completion should be placed in this ~/.local/share/bash-completion/completions directory.

From github:bash-completion

Q. Where should I install my own local completions?

A. Put them in the completions subdir of $BASH_COMPLETION_USER_DIR (defaults to $XDG_DATA_HOME/bash-completion or ~/.local/share/bash-completion if $XDG_DATA_HOME is not set) to have them loaded automatically on demand when the respective command is being completed. See also the next question's answer for considerations for these files' names, they apply here as well. Alternatively, you can write them directly in ~/.bash_completion which is loaded eagerly by our main script.

For system wide installation (e.g. packaging deb, ...) the completion may be placed in /etc/bash_completion.d/ .

abuGit avatar Mar 15 '22 23:03 abuGit

@abuGit - I don't think you understand my feature request.

I am asking for a completion script built-in from bat completion command directly.

Yes, bat completion command does not exist - that's what I am asking for.

tigerinus avatar Mar 15 '22 23:03 tigerinus

I would really like this, too, for zsh. It's really convenient to be able to do {tool} completion --shell {zsh|bash|fish} at install-time to also install/refresh shell completions.

petemounce avatar Sep 13 '22 14:09 petemounce

I haven't figured out a good way to get the completions when installing bat using cargo. This issue would solve the problem imo.

tolik518 avatar Nov 17 '23 13:11 tolik518