Teach bash about git-submodule and its subcommands
The git-submodule command is new in 1.5.3 and contains a number of useful subcommands for working on submodules. We usually try to offer the subcommands of a git command in the bash completion, so here they are for git-submodule. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Aug 23, 2007 at 01:50 UTC
be86f7a0dfa05dacb2ef512e99d1de576e77a633
1 file changed
+27
contrib/completion/git-completion.bash
+27
@@ -1024,6 +1024,31 @@ _git_stash ()
1024
__gitcomp 'list show apply clear'
1025
}
1026
1027
+_git_submodule ()
1028
+{
1029
+ local i c=1 command
1030
+ while [ $c -lt $COMP_CWORD ]; do
1031
+ i="${COMP_WORDS[c]}"
1032
+ case "$i" in
1033
+ add|status|init|update) command="$i"; break ;;
1034
+ esac
1035
+ c=$((++c))
1036
+ done
1037
+
1038
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
1039
+ local cur="${COMP_WORDS[COMP_CWORD]}"
1040
+ case "$cur" in
1041
+ --*)
1042
+ __gitcomp "--quiet --cached"
1043
+ ;;
1044
+ *)
1045
+ __gitcomp "add status init update"
1046
+ ;;
1047
+ esac
1048
+ return
1049
+ fi
1050
+}
1051
+
1052
_git ()
1053
{
1054
local i c=1 command __git_dir
@@ -1090,6 +1115,7 @@ _git ()
1115
show) _git_show ;;
1116
show-branch) _git_log ;;
1117
stash) _git_stash ;;
1118
+ submodule) _git_submodule ;;
1119
whatchanged) _git_log ;;
1120
*) COMPREPLY=() ;;
1121
esac
@@ -1138,6 +1164,7 @@ complete -o default -o nospace -F _git_reset git-reset
1164
complete -o default -o nospace -F _git_shortlog git-shortlog
1165
complete -o default -o nospace -F _git_show git-show
1166
complete -o default -o nospace -F _git_stash git-stash
1167
+complete -o default -o nospace -F _git_submodule git-submodule
1168
complete -o default -o nospace -F _git_log git-show-branch
1169
complete -o default -o nospace -F _git_log git-whatchanged
1170