Skip to content

Commit 50e126e

Browse files
tpavlicgitster
authored andcommitted
bash-completion: Try bash completions before simple filetype
When a git completion is not found, a bash shell should try bash-type completions first before going to standard filetype completions. This patch adds "-o bashdefault" to the completion line. If that option is not available, it uses the old method. This behavior was inspired by Mercurial's bash completion script. Signed-off-by: Ted Pavlic <[email protected]> Acked-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25a31f8 commit 50e126e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,13 +1766,16 @@ _gitk ()
17661766
__git_complete_revlist
17671767
}
17681768

1769-
complete -o default -o nospace -F _git git
1770-
complete -o default -o nospace -F _gitk gitk
1769+
complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
1770+
|| complete -o default -o nospace -F _git git
1771+
complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
1772+
|| complete -o default -o nospace -F _gitk gitk
17711773

17721774
# The following are necessary only for Cygwin, and only are needed
17731775
# when the user has tab-completed the executable name and consequently
17741776
# included the '.exe' suffix.
17751777
#
17761778
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1777-
complete -o default -o nospace -F _git git.exe
1779+
complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
1780+
|| complete -o default -o nospace -F _git git.exe
17781781
fi

0 commit comments

Comments
 (0)