Add completion for Git submodule moving and removing
This commit is contained in:
parent
6cf368cf4d
commit
8b8a883718
2 changed files with 68 additions and 0 deletions
41
modules/git/functions/_git-submodule-move
Normal file
41
modules/git/functions/_git-submodule-move
Normal file
|
@ -0,0 +1,41 @@
|
|||
#compdef git-submodule-move
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-submodule-move.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local state expl ret=1
|
||||
local -a submodules
|
||||
local submodule
|
||||
|
||||
_arguments -C -s -S \
|
||||
'1::args:->submodule' \
|
||||
'2::args:->directory' && ret=0
|
||||
|
||||
case "$state" in
|
||||
(submodule)
|
||||
while IFS=$'\n' read submodule; do
|
||||
submodules+=("$submodule")
|
||||
done < <(
|
||||
git config --file "$(git-root)/.gitmodules" --list \
|
||||
| grep '.path=' \
|
||||
| cut -d= -f2-
|
||||
)
|
||||
|
||||
_describe -t submodule 'submodules' submodules && ret=0
|
||||
;;
|
||||
(directory)
|
||||
_wanted directories expl 'directory' _path_files -/ || _message 'directory'
|
||||
;;
|
||||
esac
|
||||
|
||||
return $ret
|
||||
|
27
modules/git/functions/_git-submodule-remove
Normal file
27
modules/git/functions/_git-submodule-remove
Normal file
|
@ -0,0 +1,27 @@
|
|||
#compdef git-submodule-remove
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-submodule-remove.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local -a submodules
|
||||
local submodule
|
||||
|
||||
while IFS=$'\n' read submodule; do
|
||||
submodules+=("$submodule")
|
||||
done < <(
|
||||
git config --file "$(git-root)/.gitmodules" --list \
|
||||
| grep '.path=' \
|
||||
| cut -d= -f2-
|
||||
)
|
||||
|
||||
_describe -t submodule 'submodules' submodules && return 0
|
||||
|
Loading…
Reference in a new issue