Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Bash completion on macOS #2074

Merged
merged 4 commits into from
Feb 24, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

## Bugfixes

- Fix bash completion on bash 3.x and bash-completion 1.x. See #2066 (@joshpencheon)

## Other

## Syntaxes
Expand Down
17 changes: 15 additions & 2 deletions assets/completions/bat.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down