Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## Other

- Various bash completion improvements, see #2310 (@scop)
- Disable completion of `cache` subcommand, see #2399 (@cyqsimon)

## Syntaxes

Expand Down
3 changes: 2 additions & 1 deletion assets/completions/_bat.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -Script
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print this help message.')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Show version information.')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Show version information.')
[CompletionResult]::new('cache', 'cache', [CompletionResultType]::ParameterValue, 'Modify the syntax-definition and theme cache')
## Completion of the 'cache' command itself is removed for better UX
## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802
break
}
'{{PROJECT_EXECUTABLE}};cache' {
Expand Down
5 changes: 3 additions & 2 deletions assets/completions/bat.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ _bat() {
fi

_filedir
((cword == 1)) && COMPREPLY+=($(compgen -W cache -- "$cur"))


## Completion of the 'cache' command itself is removed for better UX
## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802
} && complete -F _bat {{PROJECT_EXECUTABLE}}
3 changes: 2 additions & 1 deletion assets/completions/bat.fish.in
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ complete -c $bat -s V -l version -f -d "Show version information" -n __fish_is_f
complete -c $bat -l wrap -x -a "$wrap_opts" -d "Text-wrapping mode" -n __bat_no_excl_args

# Sub-command 'cache' completions
complete -c $bat -a cache -d "Modify the syntax/language definition cache" -n __fish_use_subcommand
## Completion of the 'cache' command itself is removed for better UX
## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802

complete -c $bat -l build -f -d "Parse new definitions into cache" -n __bat_cache_no_excl

Expand Down
26 changes: 10 additions & 16 deletions assets/completions/bat.zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,14 @@ _{{PROJECT_EXECUTABLE}}_main() {
esac
}

# first positional argument
if (( ${#words} == 2 )); then
local -a subcommands
subcommands=('cache:Modify the syntax-definition and theme cache')
_describe subcommand subcommands
_{{PROJECT_EXECUTABLE}}_main
else
case $words[2] in
cache)
_{{PROJECT_EXECUTABLE}}_cache_subcommand
;;
case $words[2] in
cache)
## Completion of the 'cache' command itself is removed for better UX
## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802
_{{PROJECT_EXECUTABLE}}_cache_subcommand
;;

*)
_{{PROJECT_EXECUTABLE}}_main
;;
esac
fi
*)
_{{PROJECT_EXECUTABLE}}_main
;;
esac