Skip to content

Commit

Permalink
Fix bash completion with git 2.30.0 and higher
Browse files Browse the repository at this point in the history
Co-authored-by: Ches Martin <ches@whiskeyandgrits.net>
  • Loading branch information
cblecker and ches committed Mar 28, 2022
1 parent df28407 commit 9233de7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions etc/hub.bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# This script complements the completion script that ships with git.

# If there is no git tab completion, but we have the _completion loader try to load it
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
if ! declare -F __git > /dev/null && declare -F _completion_loader > /dev/null; then
_completion_loader git
fi

# Check that git tab completion is available and we haven't already set up completion
if declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then
if declare -F __git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then
# Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
Expand Down Expand Up @@ -382,6 +382,6 @@ EOF
}

# Enable completion for hub even when not using the alias
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
|| complete -o default -o nospace -F _git hub
complete -o bashdefault -o default -o nospace -F __git hub 2>/dev/null \
|| complete -o default -o nospace -F __git hub
fi

0 comments on commit 9233de7

Please sign in to comment.