@matheusbsbs / matheus-bagliano / commits / 50e126e185
Fork 0

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 <ted@tedpavlic.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ted Pavlic committed Jan 15, 2009 at 11:02 UTC 50e126e185c196b9b66dcdefb4b05f090d62dd4c
1 file changed +6 -3
contrib/completion/git-completion.bash
+6 -3
@@ -1766,13 +1766,16 @@ _gitk ()
1766 __git_complete_revlist
1767 }
1768
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
1773
1774 # The following are necessary only for Cygwin, and only are needed
1775 # when the user has tab-completed the executable name and consequently
1776 # included the '.exe' suffix.
1777 #
1778 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
1781 fi