mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 07:43:39 +01:00
fix Bash completion on macOS (#2074)
* fix Bash completion on macOS The Homebrew-provided bash-completion is version 1.x, which doesn't provide _init_completion. We add a standard shim instead. * Add entry to CHANGELOG * Update CHANGELOG.md Co-authored-by: Ville Skyttä <ville.skytta@iki.fi> * review: avoid calling _split_longopt repeatedly Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
This commit is contained in:
parent
e4f6fb2afe
commit
ad6cae433a
@ -7,6 +7,8 @@
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Fix bash completion on bash 3.x and bash-completion 1.x. See #2066 (@joshpencheon)
|
||||
|
||||
## Other
|
||||
|
||||
## Syntaxes
|
||||
|
17
assets/completions/bat.bash.in
vendored
17
assets/completions/bat.bash.in
vendored
@ -2,9 +2,22 @@
|
||||
|
||||
# Requires https://github.com/scop/bash-completion
|
||||
|
||||
# Macs have bash3 for which the bash-completion package doesn't include
|
||||
# _init_completion. This is a minimal version of that function.
|
||||
__bat_init_completion()
|
||||
{
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref "$@" cur prev words cword
|
||||
}
|
||||
|
||||
_bat() {
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return 0
|
||||
local cur prev words cword split=false
|
||||
if declare -F _init_completion >/dev/null 2>&1; then
|
||||
_init_completion -s || return 0
|
||||
else
|
||||
__bat_init_completion -n "=" || return 0
|
||||
_split_longopt && split=true
|
||||
fi
|
||||
|
||||
if [[ ${words[1]-} == cache ]]; then
|
||||
case $prev in
|
||||
|
Loading…
Reference in New Issue
Block a user