mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-09-21 02:17:11 +00:00
style(completions/...): fix indentation
* style(completions/defaults): fix indentation * style(completions/{gh,hub}): fix indentation * style(completions/git_flow_avh): adjust indentation * style(completions/go): adjust indentation * style(completions/gradle): adjust indentation * style(completions/maven): adjust indentation * style(completions/salt): adjust indentation * style(completions/sdkman): adjust indentation * style(completions/tmux): adjust indentation * style(completions/vagrant): adjust indentation * style(completions/virtualbox): adjust indentation
This commit is contained in:
parent
1a57a3f113
commit
7ddbf0b541
@ -7,141 +7,140 @@
|
||||
#
|
||||
# Version 1.0 (2006-11-08)
|
||||
|
||||
|
||||
_defaults_domains()
|
||||
{
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" )
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $domains )
|
||||
if [[ $( echo '-app' | grep "^$cur" ) ]]; then
|
||||
COMPREPLY[${#COMPREPLY[@]}]="-app"
|
||||
fi
|
||||
local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" )
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $domains )
|
||||
if [[ $( echo '-app' | grep "^$cur" ) ]]; then
|
||||
COMPREPLY[${#COMPREPLY[@]}]="-app"
|
||||
fi
|
||||
|
||||
return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
_defaults()
|
||||
{
|
||||
local cur prev host_opts cmds cmd domain keys key_index
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur prev host_opts cmds cmd domain keys key_index
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
host_opts='-currentHost -host'
|
||||
cmds='read read-type write rename delete domains find help'
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||
COMPREPLY=( $( compgen -W "$host_opts $cmds" -- $cur ) )
|
||||
return 0
|
||||
elif [[ $COMP_CWORD -eq 2 ]]; then
|
||||
if [[ "$prev" == "-currentHost" ]]; then
|
||||
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
|
||||
return 0
|
||||
elif [[ "$prev" == "-host" ]]; then
|
||||
return 0
|
||||
_known_hosts -a
|
||||
else
|
||||
_defaults_domains
|
||||
return 0
|
||||
fi
|
||||
elif [[ $COMP_CWORD -eq 3 ]]; then
|
||||
if [[ ${COMP_WORDS[1]} == "-host" ]]; then
|
||||
_defaults_domains
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Both a domain and command have been specified
|
||||
|
||||
if [[ ${COMP_WORDS[1]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[1]}
|
||||
domain=${COMP_WORDS[2]}
|
||||
key_index=3
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 3 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[3]}"
|
||||
key_index=4
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[2]} == "-currentHost" ]] && [[ ${COMP_WORDS[2]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[2]}
|
||||
domain=${COMP_WORDS[3]}
|
||||
key_index=4
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 4 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[4]}"
|
||||
key_index=5
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[3]} == "-host" ]] && [[ ${COMP_WORDS[3]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[3]}
|
||||
domain=${COMP_WORDS[4]}
|
||||
key_index=5
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 5 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[5]}"
|
||||
key_index=6
|
||||
fi
|
||||
fi
|
||||
|
||||
keys=$( defaults read $domain 2>/dev/null | sed -n -e '/^ [^}) ]/p' | sed -e 's/^ \([^" ]\{1,\}\) = .*$/\1/g' -e 's/^ "\([^"]\{1,\}\)" = .*$/\1/g' | sed -e 's/ /\\ /g' )
|
||||
|
||||
case $cmd in
|
||||
read|read-type)
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
;;
|
||||
write)
|
||||
if [[ $key_index -eq $COMP_CWORD ]]; then
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
elif [[ $((key_index+1)) -eq $COMP_CWORD ]]; then
|
||||
# Complete value type
|
||||
# Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
|
||||
local value_types='-string -data -integer -float -boolean -date -array -array-add -dict -dict-add'
|
||||
local cur_type=$( defaults read-type $domain ${COMP_WORDS[key_index]} 2>/dev/null | sed -e 's/^Type is \(.*\)/-\1/' -e's/dictionary/dict/' | grep "^$cur" )
|
||||
if [[ $cur_type ]]; then
|
||||
COMPREPLY=( $cur_type )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W "$value_types" -- $cur ) )
|
||||
fi
|
||||
elif [[ $((key_index+2)) -eq $COMP_CWORD ]]; then
|
||||
# Complete value
|
||||
# Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
|
||||
COMPREPLY=( $( defaults read $domain ${COMP_WORDS[key_index]} 2>/dev/null | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
rename)
|
||||
if [[ $key_index -eq $COMP_CWORD ]] ||
|
||||
[[ $((key_index+1)) -eq $COMP_CWORD ]]; then
|
||||
# Complete source and destination keys
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
delete)
|
||||
if [[ $key_index -eq $COMP_CWORD ]]; then
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
host_opts='-currentHost -host'
|
||||
cmds='read read-type write rename delete domains find help'
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||
COMPREPLY=( $( compgen -W "$host_opts $cmds" -- $cur ) )
|
||||
return 0
|
||||
elif [[ $COMP_CWORD -eq 2 ]]; then
|
||||
if [[ "$prev" == "-currentHost" ]]; then
|
||||
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
|
||||
return 0
|
||||
elif [[ "$prev" == "-host" ]]; then
|
||||
return 0
|
||||
_known_hosts -a
|
||||
else
|
||||
_defaults_domains
|
||||
return 0
|
||||
fi
|
||||
elif [[ $COMP_CWORD -eq 3 ]]; then
|
||||
if [[ ${COMP_WORDS[1]} == "-host" ]]; then
|
||||
_defaults_domains
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Both a domain and command have been specified
|
||||
|
||||
if [[ ${COMP_WORDS[1]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[1]}
|
||||
domain=${COMP_WORDS[2]}
|
||||
key_index=3
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 3 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[3]}"
|
||||
key_index=4
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[2]} == "-currentHost" ]] && [[ ${COMP_WORDS[2]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[2]}
|
||||
domain=${COMP_WORDS[3]}
|
||||
key_index=4
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 4 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[4]}"
|
||||
key_index=5
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[3]} == "-host" ]] && [[ ${COMP_WORDS[3]} == [${cmds// /|}] ]]; then
|
||||
cmd=${COMP_WORDS[3]}
|
||||
domain=${COMP_WORDS[4]}
|
||||
key_index=5
|
||||
if [[ "$domain" == "-app" ]]; then
|
||||
if [[ $COMP_CWORD -eq 5 ]]; then
|
||||
# Completing application name. Can't help here, sorry
|
||||
return 0
|
||||
fi
|
||||
domain="-app ${COMP_WORDS[5]}"
|
||||
key_index=6
|
||||
fi
|
||||
fi
|
||||
|
||||
keys=$( defaults read $domain 2>/dev/null | sed -n -e '/^ [^}) ]/p' | sed -e 's/^ \([^" ]\{1,\}\) = .*$/\1/g' -e 's/^ "\([^"]\{1,\}\)" = .*$/\1/g' | sed -e 's/ /\\ /g' )
|
||||
|
||||
case $cmd in
|
||||
read|read-type)
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
;;
|
||||
write)
|
||||
if [[ $key_index -eq $COMP_CWORD ]]; then
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
elif [[ $((key_index+1)) -eq $COMP_CWORD ]]; then
|
||||
# Complete value type
|
||||
# Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
|
||||
local value_types='-string -data -integer -float -boolean -date -array -array-add -dict -dict-add'
|
||||
local cur_type=$( defaults read-type $domain ${COMP_WORDS[key_index]} 2>/dev/null | sed -e 's/^Type is \(.*\)/-\1/' -e's/dictionary/dict/' | grep "^$cur" )
|
||||
if [[ $cur_type ]]; then
|
||||
COMPREPLY=( $cur_type )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W "$value_types" -- $cur ) )
|
||||
fi
|
||||
elif [[ $((key_index+2)) -eq $COMP_CWORD ]]; then
|
||||
# Complete value
|
||||
# Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
|
||||
COMPREPLY=( $( defaults read $domain ${COMP_WORDS[key_index]} 2>/dev/null | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
rename)
|
||||
if [[ $key_index -eq $COMP_CWORD ]] ||
|
||||
[[ $((key_index+1)) -eq $COMP_CWORD ]]; then
|
||||
# Complete source and destination keys
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
delete)
|
||||
if [[ $key_index -eq $COMP_CWORD ]]; then
|
||||
# Complete key
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _defaults -o default defaults
|
||||
|
@ -38,17 +38,17 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -65,16 +65,16 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -82,14 +82,14 @@ EOF
|
||||
__gitcomp "$u -- $(__hub_github_repos '\p')"
|
||||
elif [ -z "$subpage" ]; then
|
||||
case "$cur" in
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
__gitcomp "$u"
|
||||
@ -102,26 +102,26 @@ EOF
|
||||
while [ $c -gt 1 ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
;;
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
arg_repo=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c--))
|
||||
done
|
||||
@ -163,20 +163,20 @@ EOF
|
||||
|
||||
local pfx cur_="$cur"
|
||||
case "$cur_" in
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -186,16 +186,16 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -203,12 +203,12 @@ EOF
|
||||
repo=$(basename "$PWD")
|
||||
fi
|
||||
case "$prev" in
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -218,9 +218,9 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
--no-remote)
|
||||
unset remote
|
||||
;;
|
||||
--no-remote)
|
||||
unset remote
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -235,33 +235,33 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-m|-F|-i|-b|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-m|-F|-i|-b|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -364,4 +364,3 @@ EOF
|
||||
complete -o bashdefault -o default -o nospace -F _git gh 2>/dev/null \
|
||||
|| complete -o default -o nospace -F _git gh
|
||||
fi
|
||||
|
||||
|
@ -50,461 +50,461 @@
|
||||
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||
|
||||
__git_flow_config_file_options="
|
||||
--local --global --system --file=
|
||||
"
|
||||
--local --global --system --file=
|
||||
"
|
||||
|
||||
_git_flow ()
|
||||
{
|
||||
local subcommands="init feature release hotfix support help version config finish delete publish rebase"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
local subcommands="init feature release hotfix support help version config finish delete publish rebase"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
init)
|
||||
__git_flow_init
|
||||
return
|
||||
;;
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
support)
|
||||
__git_flow_support
|
||||
return
|
||||
;;
|
||||
config)
|
||||
__git_flow_config
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
init)
|
||||
__git_flow_init
|
||||
return
|
||||
;;
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
support)
|
||||
__git_flow_support
|
||||
return
|
||||
;;
|
||||
config)
|
||||
__git_flow_config
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_init ()
|
||||
{
|
||||
local subcommands="help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
fi
|
||||
local subcommands="help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
fi
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nodefaults --defaults
|
||||
--noforce --force
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nodefaults --defaults
|
||||
--noforce --force
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_feature ()
|
||||
{
|
||||
local subcommands="list start finish publish track diff rebase checkout pull help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
local subcommands="list start finish publish track diff rebase checkout pull help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp_nl "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--norebase --rebase
|
||||
--nopreserve-merges --preserve-merges
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--nosquash --squash
|
||||
--no-ff
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
diff)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp_nl "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--norebase --rebase
|
||||
--nopreserve-merges --preserve-merges
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--nosquash --squash
|
||||
--no-ff
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
diff)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_release ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
--nosquash --squash
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
--nosquash --squash
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
__git_flow_hotfix ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_support ()
|
||||
{
|
||||
local subcommands="list start help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
local subcommands="list start help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'support')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'support')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_config ()
|
||||
{
|
||||
local subcommands="list set base"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
local subcommands="list set base"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
set)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp "
|
||||
master develop
|
||||
feature hotfix release support
|
||||
versiontagprefix
|
||||
"
|
||||
return
|
||||
;;
|
||||
base)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
set get
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
case "$subcommand" in
|
||||
set)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp "
|
||||
master develop
|
||||
feature hotfix release support
|
||||
versiontagprefix
|
||||
"
|
||||
return
|
||||
;;
|
||||
base)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
set get
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_prefix ()
|
||||
{
|
||||
case "$1" in
|
||||
feature|release|hotfix|support)
|
||||
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
case "$1" in
|
||||
feature|release|hotfix|support)
|
||||
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_local_branches ()
|
||||
{
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref#$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref#$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
|
||||
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
__git_flow_list_remote_branches ()
|
||||
{
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
_omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
_omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
}
|
||||
|
||||
__git_flow_list_branches ()
|
||||
{
|
||||
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
|
||||
fi
|
||||
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
|
||||
fi
|
||||
}
|
||||
|
||||
# alias __git_find_on_cmdline for backwards compatibility
|
||||
if [ -z "`type -t __git_find_on_cmdline`" ]; then
|
||||
alias __git_find_on_cmdline=__git_find_subcommand
|
||||
alias __git_find_on_cmdline=__git_find_subcommand
|
||||
fi
|
||||
|
@ -14,7 +14,7 @@ function _go_clear_cache {
|
||||
unset _go_imports
|
||||
}
|
||||
function _go_importpath_cache {
|
||||
if [ -z "$_go_imports" ]; then
|
||||
if [ -z "$_go_imports" ]; then
|
||||
_go_imports=$(go list all 2>/dev/null)
|
||||
export _go_imports
|
||||
fi
|
||||
@ -53,226 +53,226 @@ _go()
|
||||
fi
|
||||
|
||||
case "$cmd" in
|
||||
'build')
|
||||
case "$prev" in
|
||||
'-o')
|
||||
_filedir
|
||||
;;
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -o -p -v -x" -- "$cur"))
|
||||
else
|
||||
local found=0
|
||||
for ((i=0; i < ${#COMP_WORDS[@]}; i++)); do
|
||||
case "$i" in
|
||||
0|1|"$COMP_CWORD")
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
local opt="${COMP_WORDS[i]}"
|
||||
if [[ "$opt" != -* ]]; then
|
||||
if [[ "$opt" == *.go && -f "$opt" ]]; then
|
||||
found=1
|
||||
break
|
||||
else
|
||||
found=2
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
case "$found" in
|
||||
0)
|
||||
_filedir go
|
||||
_go_importpath_cache
|
||||
COMPREPLY+=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
1)
|
||||
_filedir go
|
||||
;;
|
||||
2)
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
'build')
|
||||
case "$prev" in
|
||||
'-o')
|
||||
_filedir
|
||||
;;
|
||||
'clean')
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-i -r -n -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
'doc')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'env')
|
||||
COMPREPLY=($(compgen -W "$env_vars" -- "$cur"))
|
||||
;;
|
||||
'fix')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'fmt')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'get')
|
||||
case "$prev" in
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -d -fix -n -p -u -v -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'install')
|
||||
case "$prev" in
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -p -v -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'list')
|
||||
case "$prev" in
|
||||
'-f')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-e -f -json" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'run')
|
||||
if [[ "$cur" == -* && "$prev" != *.go ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -x" -- "$cur"))
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
;;
|
||||
'test') # TODO: Support for testflags.
|
||||
case "$prev" in
|
||||
'-file')
|
||||
_filedir go
|
||||
;;
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-c -file -i -p -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'tool')
|
||||
if [ "$COMP_CWORD" == 2 ]; then
|
||||
COMPREPLY=($(compgen -W "$(go tool)" -- "$cur"))
|
||||
else
|
||||
case "${COMP_WORDS[2]}" in
|
||||
[568]a) # TODO: Implement something.
|
||||
#_go_tool_568a
|
||||
;;
|
||||
[568]c) # TODO: Implement something.
|
||||
#_go_tool_568c
|
||||
;;
|
||||
[568]g) # TODO: Implement something.
|
||||
#_go_tool_568g
|
||||
;;
|
||||
[568]l) # TODO: Implement something.
|
||||
#_go_tool_568l
|
||||
;;
|
||||
'api') # TODO: Implement something.
|
||||
#_go_tool_api
|
||||
;;
|
||||
'cgo') # TODO: Implement something.
|
||||
#_go_tool_cgo
|
||||
;;
|
||||
'cov') # TODO: Implement something.
|
||||
#_go_tool_cov
|
||||
;;
|
||||
'dist') # TODO: Implement something.
|
||||
#_go_tool_dist
|
||||
;;
|
||||
'ebnflint') # TODO: Implement something.
|
||||
#_go_tool_ebnflint
|
||||
;;
|
||||
'fix') # TODO: Implement something.
|
||||
#_go_tool_fix
|
||||
;;
|
||||
'gotype') # TODO: Implement something.
|
||||
#_go_tool_gotype
|
||||
;;
|
||||
'nm') # TODO: Implement something.
|
||||
#_go_tool_nm
|
||||
;;
|
||||
'pack') # TODO: Implement something.
|
||||
#_go_tool_pack
|
||||
;;
|
||||
'pprof') # TODO: Implement something.
|
||||
#_go_tool_pprof
|
||||
;;
|
||||
'prof') # TODO: Implement something.
|
||||
#_go_tool_prof
|
||||
;;
|
||||
'vet') # TODO: Implement something.
|
||||
#_go_tool_vet
|
||||
;;
|
||||
'yacc') # TODO: Implement something.
|
||||
#_go_tool_yacc
|
||||
;;
|
||||
esac
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "${COMPREPLY[*]} -h" -- "$cur"))
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'version')
|
||||
;;
|
||||
'vet')
|
||||
if [[ "$cur" == -* ]]; then
|
||||
:
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
'help')
|
||||
if [ "$COMP_CWORD" == 2 ]; then
|
||||
COMPREPLY=($(compgen -W "$cmds $addhelp" -- "$cur"))
|
||||
fi
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [ "$COMP_CWORD" == 1 ]; then
|
||||
COMPREPLY=($(compgen -W "$cmds $other" -- "$cur"))
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -o -p -v -x" -- "$cur"))
|
||||
else
|
||||
_filedir
|
||||
local found=0
|
||||
for ((i=0; i < ${#COMP_WORDS[@]}; i++)); do
|
||||
case "$i" in
|
||||
0|1|"$COMP_CWORD")
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
local opt="${COMP_WORDS[i]}"
|
||||
if [[ "$opt" != -* ]]; then
|
||||
if [[ "$opt" == *.go && -f "$opt" ]]; then
|
||||
found=1
|
||||
break
|
||||
else
|
||||
found=2
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
case "$found" in
|
||||
0)
|
||||
_filedir go
|
||||
_go_importpath_cache
|
||||
COMPREPLY+=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
1)
|
||||
_filedir go
|
||||
;;
|
||||
2)
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'clean')
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-i -r -n -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
'doc')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'env')
|
||||
COMPREPLY=($(compgen -W "$env_vars" -- "$cur"))
|
||||
;;
|
||||
'fix')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'fmt')
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
;;
|
||||
'get')
|
||||
case "$prev" in
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -d -fix -n -p -u -v -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'install')
|
||||
case "$prev" in
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -p -v -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'list')
|
||||
case "$prev" in
|
||||
'-f')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-e -f -json" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'run')
|
||||
if [[ "$cur" == -* && "$prev" != *.go ]]; then
|
||||
COMPREPLY=($(compgen -W "-a -n -x" -- "$cur"))
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
;;
|
||||
'test') # TODO: Support for testflags.
|
||||
case "$prev" in
|
||||
'-file')
|
||||
_filedir go
|
||||
;;
|
||||
'-p')
|
||||
;;
|
||||
*)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-c -file -i -p -x" -- "$cur"))
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
'tool')
|
||||
if [ "$COMP_CWORD" == 2 ]; then
|
||||
COMPREPLY=($(compgen -W "$(go tool)" -- "$cur"))
|
||||
else
|
||||
case "${COMP_WORDS[2]}" in
|
||||
[568]a) # TODO: Implement something.
|
||||
#_go_tool_568a
|
||||
;;
|
||||
[568]c) # TODO: Implement something.
|
||||
#_go_tool_568c
|
||||
;;
|
||||
[568]g) # TODO: Implement something.
|
||||
#_go_tool_568g
|
||||
;;
|
||||
[568]l) # TODO: Implement something.
|
||||
#_go_tool_568l
|
||||
;;
|
||||
'api') # TODO: Implement something.
|
||||
#_go_tool_api
|
||||
;;
|
||||
'cgo') # TODO: Implement something.
|
||||
#_go_tool_cgo
|
||||
;;
|
||||
'cov') # TODO: Implement something.
|
||||
#_go_tool_cov
|
||||
;;
|
||||
'dist') # TODO: Implement something.
|
||||
#_go_tool_dist
|
||||
;;
|
||||
'ebnflint') # TODO: Implement something.
|
||||
#_go_tool_ebnflint
|
||||
;;
|
||||
'fix') # TODO: Implement something.
|
||||
#_go_tool_fix
|
||||
;;
|
||||
'gotype') # TODO: Implement something.
|
||||
#_go_tool_gotype
|
||||
;;
|
||||
'nm') # TODO: Implement something.
|
||||
#_go_tool_nm
|
||||
;;
|
||||
'pack') # TODO: Implement something.
|
||||
#_go_tool_pack
|
||||
;;
|
||||
'pprof') # TODO: Implement something.
|
||||
#_go_tool_pprof
|
||||
;;
|
||||
'prof') # TODO: Implement something.
|
||||
#_go_tool_prof
|
||||
;;
|
||||
'vet') # TODO: Implement something.
|
||||
#_go_tool_vet
|
||||
;;
|
||||
'yacc') # TODO: Implement something.
|
||||
#_go_tool_yacc
|
||||
;;
|
||||
esac
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "${COMPREPLY[*]} -h" -- "$cur"))
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'version')
|
||||
;;
|
||||
'vet')
|
||||
if [[ "$cur" == -* ]]; then
|
||||
:
|
||||
else
|
||||
_go_importpath_cache
|
||||
COMPREPLY=(`_go_importpath "$cur"`)
|
||||
fi
|
||||
;;
|
||||
'help')
|
||||
if [ "$COMP_CWORD" == 2 ]; then
|
||||
COMPREPLY=($(compgen -W "$cmds $addhelp" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ "$COMP_CWORD" == 1 ]; then
|
||||
COMPREPLY=($(compgen -W "$cmds $other" -- "$cur"))
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,12 @@ function __gradle {
|
||||
local cache_dir="$HOME/.gradle/completion_cache"
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
local checksum_command="find . -name build.gradle -print0 | xargs -0 md5 -q | md5 -q"
|
||||
;;
|
||||
*)
|
||||
local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1"
|
||||
;;
|
||||
darwin*)
|
||||
local checksum_command="find . -name build.gradle -print0 | xargs -0 md5 -q | md5 -q"
|
||||
;;
|
||||
*)
|
||||
local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1"
|
||||
;;
|
||||
esac
|
||||
local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'"
|
||||
|
||||
|
@ -40,17 +40,17 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -67,16 +67,16 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -84,14 +84,14 @@ EOF
|
||||
__gitcomp "$u -- $(__hub_github_repos '\p')"
|
||||
elif [ -z "$subpage" ]; then
|
||||
case "$cur" in
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
__gitcomp "$u"
|
||||
@ -104,26 +104,26 @@ EOF
|
||||
while [ $c -gt 1 ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
;;
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
arg_repo=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c--))
|
||||
done
|
||||
@ -165,20 +165,20 @@ EOF
|
||||
|
||||
local pfx cur_="$cur"
|
||||
case "$cur_" in
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -188,16 +188,16 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -205,12 +205,12 @@ EOF
|
||||
repo=$(basename "$PWD")
|
||||
fi
|
||||
case "$prev" in
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -220,9 +220,9 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
--no-remote)
|
||||
unset remote
|
||||
;;
|
||||
--no-remote)
|
||||
unset remote
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
@ -237,33 +237,33 @@ EOF
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-m|-F|-i|-b|-h|-a|-M|-l)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-m|-F|-i|-b|-h|-a|-M|-l)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h|-a|-M|-l)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h|-a|-M|-l)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -6,258 +6,258 @@
|
||||
|
||||
function_exists()
|
||||
{
|
||||
_omb_util_function_exists "$1"
|
||||
return "$?"
|
||||
_omb_util_function_exists "$1"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
function_exists _get_comp_words_by_ref ||
|
||||
_get_comp_words_by_ref ()
|
||||
{
|
||||
local exclude cur_ words_ cword_;
|
||||
if [ "$1" = "-n" ]; then
|
||||
exclude=$2;
|
||||
shift 2;
|
||||
fi;
|
||||
__git_reassemble_comp_words_by_ref "$exclude";
|
||||
cur_=${words_[cword_]};
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
cur)
|
||||
cur=$cur_
|
||||
;;
|
||||
prev)
|
||||
prev=${words_[$cword_-1]}
|
||||
;;
|
||||
words)
|
||||
words=("${words_[@]}")
|
||||
;;
|
||||
cword)
|
||||
cword=$cword_
|
||||
;;
|
||||
esac;
|
||||
shift;
|
||||
done
|
||||
local exclude cur_ words_ cword_;
|
||||
if [ "$1" = "-n" ]; then
|
||||
exclude=$2;
|
||||
shift 2;
|
||||
fi;
|
||||
__git_reassemble_comp_words_by_ref "$exclude";
|
||||
cur_=${words_[cword_]};
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
cur)
|
||||
cur=$cur_
|
||||
;;
|
||||
prev)
|
||||
prev=${words_[$cword_-1]}
|
||||
;;
|
||||
words)
|
||||
words=("${words_[@]}")
|
||||
;;
|
||||
cword)
|
||||
cword=$cword_
|
||||
;;
|
||||
esac;
|
||||
shift;
|
||||
done
|
||||
}
|
||||
|
||||
function_exists __ltrim_colon_completions ||
|
||||
__ltrim_colon_completions()
|
||||
{
|
||||
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
|
||||
# Remove colon-word prefix from COMPREPLY items
|
||||
local colon_word=${1%${1##*:}}
|
||||
local i=${#COMPREPLY[*]}
|
||||
while [[ $((--i)) -ge 0 ]]; do
|
||||
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
|
||||
done
|
||||
fi
|
||||
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
|
||||
# Remove colon-word prefix from COMPREPLY items
|
||||
local colon_word=${1%${1##*:}}
|
||||
local i=${#COMPREPLY[*]}
|
||||
while [[ $((--i)) -ge 0 ]]; do
|
||||
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function_exists __find_mvn_projects ||
|
||||
__find_mvn_projects()
|
||||
{
|
||||
find . -name 'pom.xml' -not -path '*/target/*' -prune | while read LINE ; do
|
||||
local withoutPom=${LINE%/pom.xml}
|
||||
local module=${withoutPom#./}
|
||||
if [[ -z ${module} ]]; then
|
||||
echo "."
|
||||
else
|
||||
echo ${module}
|
||||
fi
|
||||
done
|
||||
find . -name 'pom.xml' -not -path '*/target/*' -prune | while read LINE ; do
|
||||
local withoutPom=${LINE%/pom.xml}
|
||||
local module=${withoutPom#./}
|
||||
if [[ -z ${module} ]]; then
|
||||
echo "."
|
||||
else
|
||||
echo ${module}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function_exists _realpath ||
|
||||
_realpath ()
|
||||
{
|
||||
if [[ -f "$1" ]]
|
||||
if [[ -f "$1" ]]
|
||||
then
|
||||
# file *must* exist
|
||||
if cd "$(echo "${1%/*}")" &>/dev/null
|
||||
then
|
||||
# file *must* exist
|
||||
if cd "$(echo "${1%/*}")" &>/dev/null
|
||||
then
|
||||
# file *may* not be local
|
||||
# exception is ./file.ext
|
||||
# try 'cd .; cd -;' *works!*
|
||||
local tmppwd="$PWD"
|
||||
cd - &>/dev/null
|
||||
else
|
||||
# file *must* be local
|
||||
local tmppwd="$PWD"
|
||||
fi
|
||||
# file *may* not be local
|
||||
# exception is ./file.ext
|
||||
# try 'cd .; cd -;' *works!*
|
||||
local tmppwd="$PWD"
|
||||
cd - &>/dev/null
|
||||
else
|
||||
# file *cannot* exist
|
||||
return 1 # failure
|
||||
# file *must* be local
|
||||
local tmppwd="$PWD"
|
||||
fi
|
||||
else
|
||||
# file *cannot* exist
|
||||
return 1 # failure
|
||||
fi
|
||||
|
||||
# reassemble realpath
|
||||
echo "$tmppwd"/"${1##*/}"
|
||||
return 1 #success
|
||||
# reassemble realpath
|
||||
echo "$tmppwd"/"${1##*/}"
|
||||
return 1 #success
|
||||
}
|
||||
|
||||
function_exists __pom_hierarchy ||
|
||||
__pom_hierarchy()
|
||||
{
|
||||
local pom=`_realpath "pom.xml"`
|
||||
local pom=`_realpath "pom.xml"`
|
||||
POM_HIERARCHY+=("$pom")
|
||||
while [ -n "$pom" ] && grep -q "<parent>" "$pom"; do
|
||||
## look for a new relativePath for parent pom.xml
|
||||
local parent_pom_relative=`grep -e "<relativePath>.*</relativePath>" "$pom" | sed 's/.*<relativePath>//' | sed 's/<\/relativePath>.*//g'`
|
||||
|
||||
## <parent> is present but not defined, assume ../pom.xml
|
||||
if [ -z "$parent_pom_relative" ]; then
|
||||
parent_pom_relative="../pom.xml"
|
||||
fi
|
||||
|
||||
## if pom exists continue else break
|
||||
parent_pom=`_realpath "${pom%/*}/$parent_pom_relative"`
|
||||
if [ -n "$parent_pom" ]; then
|
||||
pom=$parent_pom
|
||||
else
|
||||
break
|
||||
fi
|
||||
POM_HIERARCHY+=("$pom")
|
||||
while [ -n "$pom" ] && grep -q "<parent>" "$pom"; do
|
||||
## look for a new relativePath for parent pom.xml
|
||||
local parent_pom_relative=`grep -e "<relativePath>.*</relativePath>" "$pom" | sed 's/.*<relativePath>//' | sed 's/<\/relativePath>.*//g'`
|
||||
|
||||
## <parent> is present but not defined, assume ../pom.xml
|
||||
if [ -z "$parent_pom_relative" ]; then
|
||||
parent_pom_relative="../pom.xml"
|
||||
fi
|
||||
|
||||
## if pom exists continue else break
|
||||
parent_pom=`_realpath "${pom%/*}/$parent_pom_relative"`
|
||||
if [ -n "$parent_pom" ]; then
|
||||
pom=$parent_pom
|
||||
else
|
||||
break
|
||||
fi
|
||||
POM_HIERARCHY+=("$pom")
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
_mvn()
|
||||
{
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
POM_HIERARCHY=()
|
||||
__pom_hierarchy
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
POM_HIERARCHY=()
|
||||
__pom_hierarchy
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
|
||||
local opts="-am|-amd|-B|-C|-c|-cpu|-D|-e|-emp|-ep|-f|-fae|-ff|-fn|-gs|-h|-l|-N|-npr|-npu|-nsu|-o|-P|-pl|-q|-rf|-s|-T|-t|-U|-up|-V|-v|-X"
|
||||
local long_opts="--also-make|--also-make-dependents|--batch-mode|--strict-checksums|--lax-checksums|--check-plugin-updates|--define|--errors|--encrypt-master-password|--encrypt-password|--file|--fail-at-end|--fail-fast|--fail-never|--global-settings|--help|--log-file|--non-recursive|--no-plugin-registry|--no-plugin-updates|--no-snapshot-updates|--offline|--activate-profiles|--projects|--quiet|--resume-from|--settings|--threads|--toolchains|--update-snapshots|--update-plugins|--show-version|--version|--debug"
|
||||
local opts="-am|-amd|-B|-C|-c|-cpu|-D|-e|-emp|-ep|-f|-fae|-ff|-fn|-gs|-h|-l|-N|-npr|-npu|-nsu|-o|-P|-pl|-q|-rf|-s|-T|-t|-U|-up|-V|-v|-X"
|
||||
local long_opts="--also-make|--also-make-dependents|--batch-mode|--strict-checksums|--lax-checksums|--check-plugin-updates|--define|--errors|--encrypt-master-password|--encrypt-password|--file|--fail-at-end|--fail-fast|--fail-never|--global-settings|--help|--log-file|--non-recursive|--no-plugin-registry|--no-plugin-updates|--no-snapshot-updates|--offline|--activate-profiles|--projects|--quiet|--resume-from|--settings|--threads|--toolchains|--update-snapshots|--update-plugins|--show-version|--version|--debug"
|
||||
|
||||
local common_clean_lifecycle="pre-clean|clean|post-clean"
|
||||
local common_default_lifecycle="validate|initialize|generate-sources|process-sources|generate-resources|process-resources|compile|process-classes|generate-test-sources|process-test-sources|generate-test-resources|process-test-resources|test-compile|process-test-classes|test|prepare-package|package|pre-integration-test|integration-test|post-integration-test|verify|install|deploy"
|
||||
local common_site_lifecycle="pre-site|site|post-site|site-deploy"
|
||||
local common_lifecycle_phases="${common_clean_lifecycle}|${common_default_lifecycle}|${common_site_lifecycle}"
|
||||
local common_clean_lifecycle="pre-clean|clean|post-clean"
|
||||
local common_default_lifecycle="validate|initialize|generate-sources|process-sources|generate-resources|process-resources|compile|process-classes|generate-test-sources|process-test-sources|generate-test-resources|process-test-resources|test-compile|process-test-classes|test|prepare-package|package|pre-integration-test|integration-test|post-integration-test|verify|install|deploy"
|
||||
local common_site_lifecycle="pre-site|site|post-site|site-deploy"
|
||||
local common_lifecycle_phases="${common_clean_lifecycle}|${common_default_lifecycle}|${common_site_lifecycle}"
|
||||
|
||||
local plugin_goals_appengine="appengine:backends_configure|appengine:backends_delete|appengine:backends_rollback|appengine:backends_start|appengine:backends_stop|appengine:backends_update|appengine:debug|appengine:devserver|appengine:devserver_start|appengine:devserver_stop|appengine:endpoints_get_client_lib|appengine:endpoints_get_discovery_doc|appengine:enhance|appengine:rollback|appengine:set_default_version|appengine:start_module_version|appengine:stop_module_version|appengine:update|appengine:update_cron|appengine:update_dos|appengine:update_indexes|appengine:update_queues|appengine:vacuum_indexes"
|
||||
local plugin_goals_android="android:apk|android:apklib|android:clean|android:deploy|android:deploy-dependencies|android:dex|android:emulator-start|android:emulator-stop|android:emulator-stop-all|android:generate-sources|android:help|android:instrument|android:manifest-update|android:pull|android:push|android:redeploy|android:run|android:undeploy|android:unpack|android:version-update|android:zipalign|android:devices"
|
||||
local plugin_goals_ant="ant:ant|ant:clean"
|
||||
local plugin_goals_antrun="antrun:run"
|
||||
local plugin_goals_archetype="archetype:generate|archetype:create-from-project|archetype:crawl"
|
||||
local plugin_goals_assembly="assembly:single|assembly:assembly"
|
||||
local plugin_goals_build_helper="build-helper:add-resource|build-helper:add-source|build-helper:add-test-resource|build-helper:add-test-source|build-helper:attach-artifact|build-helper:bsh-property|build-helper:cpu-count|build-helper:help|build-helper:local-ip|build-helper:maven-version|build-helper:parse-version|build-helper:regex-properties|build-helper:regex-property|build-helper:released-version|build-helper:remove-project-artifact|build-helper:reserve-network-port|build-helper:timestamp-property"
|
||||
local plugin_goals_buildnumber="buildnumber:create|buildnumber:create-timestamp|buildnumber:help|buildnumber:hgchangeset"
|
||||
local plugin_goals_cargo="cargo:start|cargo:run|cargo:stop|cargo:deploy|cargo:undeploy|cargo:help"
|
||||
local plugin_goals_checkstyle="checkstyle:checkstyle|checkstyle:check"
|
||||
local plugin_goals_cobertura="cobertura:cobertura"
|
||||
local plugin_goals_findbugs="findbugs:findbugs|findbugs:gui|findbugs:help"
|
||||
local plugin_goals_dependency="dependency:analyze|dependency:analyze-dep-mgt|dependency:analyze-duplicate|dependency:analyze-only|dependency:analyze-report|dependency:build-classpath|dependency:copy|dependency:copy-dependencies|dependency:get|dependency:go-offline|dependency:help|dependency:list|dependency:list-repositories|dependency:properties|dependency:purge-local-repository|dependency:resolve|dependency:resolve-plugins|dependency:sources|dependency:tree|dependency:unpack|dependency:unpack-dependencies"
|
||||
local plugin_goals_deploy="deploy:deploy-file"
|
||||
local plugin_goals_ear="ear:ear|ear:generate-application-xml"
|
||||
local plugin_goals_eclipse="eclipse:clean|eclipse:eclipse"
|
||||
local plugin_goals_ejb="ejb:ejb"
|
||||
local plugin_goals_enforcer="enforcer:enforce|enforcer:display-info"
|
||||
local plugin_goals_exec="exec:exec|exec:java"
|
||||
local plugin_goals_failsafe="failsafe:integration-test|failsafe:verify"
|
||||
local plugin_goals_flyway="flyway:migrate|flyway:clean|flyway:info|flyway:validate|flyway:baseline|flyway:repair"
|
||||
local plugin_goals_gpg="gpg:sign|gpg:sign-and-deploy-file"
|
||||
local plugin_goals_grails="grails:clean|grails:config-directories|grails:console|grails:create-controller|grails:create-domain-class|grails:create-integration-test|grails:create-pom|grails:create-script|grails:create-service|grails:create-tag-lib|grails:create-unit-test|grails:exec|grails:generate-all|grails:generate-controller|grails:generate-views|grails:help|grails:init|grails:init-plugin|grails:install-templates|grails:list-plugins|grails:maven-clean|grails:maven-compile|grails:maven-functional-test|grails:maven-grails-app-war|grails:maven-test|grails:maven-war|grails:package|grails:package-plugin|grails:run-app|grails:run-app-https|grails:run-war|grails:set-version|grails:test-app|grails:upgrade|grails:validate|grails:validate-plugin|grails:war"
|
||||
local plugin_goals_gwt="gwt:browser|gwt:clean|gwt:compile|gwt:compile-report|gwt:css|gwt:debug|gwt:eclipse|gwt:eclipseTest|gwt:generateAsync|gwt:help|gwt:i18n|gwt:mergewebxml|gwt:resources|gwt:run|gwt:run-codeserver|gwt:sdkInstall|gwt:source-jar|gwt:soyc|gwt:test"
|
||||
local plugin_goals_help="help:active-profiles|help:all-profiles|help:describe|help:effective-pom|help:effective-settings|help:evaluate|help:expressions|help:help|help:system"
|
||||
local plugin_goals_hibernate3="hibernate3:hbm2ddl|hibernate3:help"
|
||||
local plugin_goals_idea="idea:clean|idea:idea"
|
||||
local plugin_goals_install="install:install-file"
|
||||
local plugin_goals_jacoco="jacoco:check|jacoco:dump|jacoco:help|jacoco:instrument|jacoco:merge|jacoco:prepare-agent|jacoco:prepare-agent-integration|jacoco:report|jacoco:report-integration|jacoco:restore-instrumented-classes"
|
||||
local plugin_goals_javadoc="javadoc:javadoc|javadoc:jar|javadoc:aggregate"
|
||||
local plugin_goals_jboss="jboss:start|jboss:stop|jboss:deploy|jboss:undeploy|jboss:redeploy"
|
||||
local plugin_goals_jboss_as="jboss-as:add-resource|jboss-as:deploy|jboss-as:deploy-only|jboss-as:deploy-artifact|jboss-as:redeploy|jboss-as:redeploy-only|jboss-as:undeploy|jboss-as:undeploy-artifact|jboss-as:run|jboss-as:start|jboss-as:shutdown|jboss-as:execute-commands"
|
||||
local plugin_goals_jetty="jetty:run|jetty:run-exploded|jetty:run-forked"
|
||||
local plugin_goals_jetty="jetty:run|jetty:run-exploded|jetty:run-forked"
|
||||
#mvn help:describe -Dplugin=com.google.cloud.tools:jib-maven-plugin:1.2.0
|
||||
local plugin_goals_jib="jib:_skaffold-files|jib:_skaffold-files-v2|jib:_skaffold-package-goals|jib:build|jib:buildTar|jib:dockerBuild"
|
||||
local plugin_goals_jxr="jxr:jxr"
|
||||
local plugin_goals_license="license:format|license:check"
|
||||
local plugin_goals_liquibase="liquibase:changelogSync|liquibase:changelogSyncSQL|liquibase:clearCheckSums|liquibase:dbDoc|liquibase:diff|liquibase:dropAll|liquibase:help|liquibase:migrate|liquibase:listLocks|liquibase:migrateSQL|liquibase:releaseLocks|liquibase:rollback|liquibase:rollbackSQL|liquibase:status|liquibase:tag|liquibase:update|liquibase:updateSQL|liquibase:updateTestingRollback"
|
||||
local plugin_goals_nexus_staging="nexus-staging:close|nexus-staging:deploy|nexus-staging:deploy-staged|nexus-staging:deploy-staged-repository|nexus-staging:drop|nexus-staging:help|nexus-staging:promote|nexus-staging:rc-close|nexus-staging:rc-drop|nexus-staging:rc-list|nexus-staging:rc-list-profiles|nexus-staging:rc-promote|nexus-staging:rc-release|nexus-staging:release"
|
||||
#mvn help:describe -Dplugin=io.quarkus:quarkus-maven-plugin:0.15.0
|
||||
local plugin_goals_quarkus="quarkus:add-extension|quarkus:add-extensions|quarkus:analyze-call-tree|quarkus:build|quarkus:create|quarkus:create-example-config|quarkus:dev|quarkus:help|quarkus:list-extensions|quarkus:native-image|quarkus:remote-dev"
|
||||
local plugin_goals_pmd="pmd:pmd|pmd:cpd|pmd:check|pmd:cpd-check"
|
||||
local plugin_goals_properties="properties:read-project-properties|properties:write-project-properties|properties:write-active-profile-properties|properties:set-system-properties"
|
||||
local plugin_goals_release="release:clean|release:prepare|release:rollback|release:perform|release:stage|release:branch|release:update-versions"
|
||||
local plugin_goals_repository="repository:bundle-create|repository:bundle-pack|repository:help"
|
||||
local plugin_goals_scala="scala:add-source|scala:cc|scala:cctest|scala:compile|scala:console|scala:doc|scala:doc-jar|scala:help|scala:run|scala:script|scala:testCompile"
|
||||
local plugin_goals_scm="scm:add|scm:checkin|scm:checkout|scm:update|scm:status"
|
||||
local plugin_goals_site="site:site|site:deploy|site:run|site:stage|site:stage-deploy"
|
||||
local plugin_goals_sonar="sonar:sonar|sonar:help"
|
||||
local plugin_goals_source="source:aggregate|source:jar|source:jar-no-fork"
|
||||
local plugin_goals_surefire="surefire:test"
|
||||
local plugin_goals_tomcat6="tomcat6:help|tomcat6:run|tomcat6:run-war|tomcat6:run-war-only|tomcat6:stop|tomcat6:deploy|tomcat6:undeploy"
|
||||
local plugin_goals_tomcat7="tomcat7:help|tomcat7:run|tomcat7:run-war|tomcat7:run-war-only|tomcat7:deploy"
|
||||
local plugin_goals_tomcat="tomcat:help|tomcat:start|tomcat:stop|tomcat:deploy|tomcat:undeploy"
|
||||
local plugin_goals_liberty="liberty:create-server|liberty:start-server|liberty:stop-server|liberty:run-server|liberty:deploy|liberty:undeploy|liberty:java-dump-server|liberty:dump-server|liberty:package-server"
|
||||
local plugin_goals_versions="versions:display-dependency-updates|versions:display-plugin-updates|versions:display-property-updates|versions:update-parent|versions:update-properties|versions:update-child-modules|versions:lock-snapshots|versions:unlock-snapshots|versions:resolve-ranges|versions:set|versions:use-releases|versions:use-next-releases|versions:use-latest-releases|versions:use-next-snapshots|versions:use-latest-snapshots|versions:use-next-versions|versions:use-latest-versions|versions:commit|versions:revert"
|
||||
local plugin_goals_vertx="vertx:init|vertx:runMod|vertx:pullInDeps|vertx:fatJar"
|
||||
local plugin_goals_war="war:war|war:exploded|war:inplace|war:manifest"
|
||||
local plugin_goals_spring_boot="spring-boot:run|spring-boot:repackage"
|
||||
local plugin_goals_jgitflow="jgitflow:feature-start|jgitflow:feature-finish|jgitflow:release-start|jgitflow:release-finish|jgitflow:hotfix-start|jgitflow:hotfix-finish|jgitflow:build-number"
|
||||
local plugin_goals_wildfly="wildfly:add-resource|wildfly:deploy|wildfly:deploy-only|wildfly:deploy-artifact|wildfly:redeploy|wildfly:redeploy-only|wildfly:undeploy|wildfly:undeploy-artifact|wildfly:run|wildfly:start|wildfly:shutdown|wildfly:execute-commands"
|
||||
local plugin_goals_appengine="appengine:backends_configure|appengine:backends_delete|appengine:backends_rollback|appengine:backends_start|appengine:backends_stop|appengine:backends_update|appengine:debug|appengine:devserver|appengine:devserver_start|appengine:devserver_stop|appengine:endpoints_get_client_lib|appengine:endpoints_get_discovery_doc|appengine:enhance|appengine:rollback|appengine:set_default_version|appengine:start_module_version|appengine:stop_module_version|appengine:update|appengine:update_cron|appengine:update_dos|appengine:update_indexes|appengine:update_queues|appengine:vacuum_indexes"
|
||||
local plugin_goals_android="android:apk|android:apklib|android:clean|android:deploy|android:deploy-dependencies|android:dex|android:emulator-start|android:emulator-stop|android:emulator-stop-all|android:generate-sources|android:help|android:instrument|android:manifest-update|android:pull|android:push|android:redeploy|android:run|android:undeploy|android:unpack|android:version-update|android:zipalign|android:devices"
|
||||
local plugin_goals_ant="ant:ant|ant:clean"
|
||||
local plugin_goals_antrun="antrun:run"
|
||||
local plugin_goals_archetype="archetype:generate|archetype:create-from-project|archetype:crawl"
|
||||
local plugin_goals_assembly="assembly:single|assembly:assembly"
|
||||
local plugin_goals_build_helper="build-helper:add-resource|build-helper:add-source|build-helper:add-test-resource|build-helper:add-test-source|build-helper:attach-artifact|build-helper:bsh-property|build-helper:cpu-count|build-helper:help|build-helper:local-ip|build-helper:maven-version|build-helper:parse-version|build-helper:regex-properties|build-helper:regex-property|build-helper:released-version|build-helper:remove-project-artifact|build-helper:reserve-network-port|build-helper:timestamp-property"
|
||||
local plugin_goals_buildnumber="buildnumber:create|buildnumber:create-timestamp|buildnumber:help|buildnumber:hgchangeset"
|
||||
local plugin_goals_cargo="cargo:start|cargo:run|cargo:stop|cargo:deploy|cargo:undeploy|cargo:help"
|
||||
local plugin_goals_checkstyle="checkstyle:checkstyle|checkstyle:check"
|
||||
local plugin_goals_cobertura="cobertura:cobertura"
|
||||
local plugin_goals_findbugs="findbugs:findbugs|findbugs:gui|findbugs:help"
|
||||
local plugin_goals_dependency="dependency:analyze|dependency:analyze-dep-mgt|dependency:analyze-duplicate|dependency:analyze-only|dependency:analyze-report|dependency:build-classpath|dependency:copy|dependency:copy-dependencies|dependency:get|dependency:go-offline|dependency:help|dependency:list|dependency:list-repositories|dependency:properties|dependency:purge-local-repository|dependency:resolve|dependency:resolve-plugins|dependency:sources|dependency:tree|dependency:unpack|dependency:unpack-dependencies"
|
||||
local plugin_goals_deploy="deploy:deploy-file"
|
||||
local plugin_goals_ear="ear:ear|ear:generate-application-xml"
|
||||
local plugin_goals_eclipse="eclipse:clean|eclipse:eclipse"
|
||||
local plugin_goals_ejb="ejb:ejb"
|
||||
local plugin_goals_enforcer="enforcer:enforce|enforcer:display-info"
|
||||
local plugin_goals_exec="exec:exec|exec:java"
|
||||
local plugin_goals_failsafe="failsafe:integration-test|failsafe:verify"
|
||||
local plugin_goals_flyway="flyway:migrate|flyway:clean|flyway:info|flyway:validate|flyway:baseline|flyway:repair"
|
||||
local plugin_goals_gpg="gpg:sign|gpg:sign-and-deploy-file"
|
||||
local plugin_goals_grails="grails:clean|grails:config-directories|grails:console|grails:create-controller|grails:create-domain-class|grails:create-integration-test|grails:create-pom|grails:create-script|grails:create-service|grails:create-tag-lib|grails:create-unit-test|grails:exec|grails:generate-all|grails:generate-controller|grails:generate-views|grails:help|grails:init|grails:init-plugin|grails:install-templates|grails:list-plugins|grails:maven-clean|grails:maven-compile|grails:maven-functional-test|grails:maven-grails-app-war|grails:maven-test|grails:maven-war|grails:package|grails:package-plugin|grails:run-app|grails:run-app-https|grails:run-war|grails:set-version|grails:test-app|grails:upgrade|grails:validate|grails:validate-plugin|grails:war"
|
||||
local plugin_goals_gwt="gwt:browser|gwt:clean|gwt:compile|gwt:compile-report|gwt:css|gwt:debug|gwt:eclipse|gwt:eclipseTest|gwt:generateAsync|gwt:help|gwt:i18n|gwt:mergewebxml|gwt:resources|gwt:run|gwt:run-codeserver|gwt:sdkInstall|gwt:source-jar|gwt:soyc|gwt:test"
|
||||
local plugin_goals_help="help:active-profiles|help:all-profiles|help:describe|help:effective-pom|help:effective-settings|help:evaluate|help:expressions|help:help|help:system"
|
||||
local plugin_goals_hibernate3="hibernate3:hbm2ddl|hibernate3:help"
|
||||
local plugin_goals_idea="idea:clean|idea:idea"
|
||||
local plugin_goals_install="install:install-file"
|
||||
local plugin_goals_jacoco="jacoco:check|jacoco:dump|jacoco:help|jacoco:instrument|jacoco:merge|jacoco:prepare-agent|jacoco:prepare-agent-integration|jacoco:report|jacoco:report-integration|jacoco:restore-instrumented-classes"
|
||||
local plugin_goals_javadoc="javadoc:javadoc|javadoc:jar|javadoc:aggregate"
|
||||
local plugin_goals_jboss="jboss:start|jboss:stop|jboss:deploy|jboss:undeploy|jboss:redeploy"
|
||||
local plugin_goals_jboss_as="jboss-as:add-resource|jboss-as:deploy|jboss-as:deploy-only|jboss-as:deploy-artifact|jboss-as:redeploy|jboss-as:redeploy-only|jboss-as:undeploy|jboss-as:undeploy-artifact|jboss-as:run|jboss-as:start|jboss-as:shutdown|jboss-as:execute-commands"
|
||||
local plugin_goals_jetty="jetty:run|jetty:run-exploded|jetty:run-forked"
|
||||
local plugin_goals_jetty="jetty:run|jetty:run-exploded|jetty:run-forked"
|
||||
#mvn help:describe -Dplugin=com.google.cloud.tools:jib-maven-plugin:1.2.0
|
||||
local plugin_goals_jib="jib:_skaffold-files|jib:_skaffold-files-v2|jib:_skaffold-package-goals|jib:build|jib:buildTar|jib:dockerBuild"
|
||||
local plugin_goals_jxr="jxr:jxr"
|
||||
local plugin_goals_license="license:format|license:check"
|
||||
local plugin_goals_liquibase="liquibase:changelogSync|liquibase:changelogSyncSQL|liquibase:clearCheckSums|liquibase:dbDoc|liquibase:diff|liquibase:dropAll|liquibase:help|liquibase:migrate|liquibase:listLocks|liquibase:migrateSQL|liquibase:releaseLocks|liquibase:rollback|liquibase:rollbackSQL|liquibase:status|liquibase:tag|liquibase:update|liquibase:updateSQL|liquibase:updateTestingRollback"
|
||||
local plugin_goals_nexus_staging="nexus-staging:close|nexus-staging:deploy|nexus-staging:deploy-staged|nexus-staging:deploy-staged-repository|nexus-staging:drop|nexus-staging:help|nexus-staging:promote|nexus-staging:rc-close|nexus-staging:rc-drop|nexus-staging:rc-list|nexus-staging:rc-list-profiles|nexus-staging:rc-promote|nexus-staging:rc-release|nexus-staging:release"
|
||||
#mvn help:describe -Dplugin=io.quarkus:quarkus-maven-plugin:0.15.0
|
||||
local plugin_goals_quarkus="quarkus:add-extension|quarkus:add-extensions|quarkus:analyze-call-tree|quarkus:build|quarkus:create|quarkus:create-example-config|quarkus:dev|quarkus:help|quarkus:list-extensions|quarkus:native-image|quarkus:remote-dev"
|
||||
local plugin_goals_pmd="pmd:pmd|pmd:cpd|pmd:check|pmd:cpd-check"
|
||||
local plugin_goals_properties="properties:read-project-properties|properties:write-project-properties|properties:write-active-profile-properties|properties:set-system-properties"
|
||||
local plugin_goals_release="release:clean|release:prepare|release:rollback|release:perform|release:stage|release:branch|release:update-versions"
|
||||
local plugin_goals_repository="repository:bundle-create|repository:bundle-pack|repository:help"
|
||||
local plugin_goals_scala="scala:add-source|scala:cc|scala:cctest|scala:compile|scala:console|scala:doc|scala:doc-jar|scala:help|scala:run|scala:script|scala:testCompile"
|
||||
local plugin_goals_scm="scm:add|scm:checkin|scm:checkout|scm:update|scm:status"
|
||||
local plugin_goals_site="site:site|site:deploy|site:run|site:stage|site:stage-deploy"
|
||||
local plugin_goals_sonar="sonar:sonar|sonar:help"
|
||||
local plugin_goals_source="source:aggregate|source:jar|source:jar-no-fork"
|
||||
local plugin_goals_surefire="surefire:test"
|
||||
local plugin_goals_tomcat6="tomcat6:help|tomcat6:run|tomcat6:run-war|tomcat6:run-war-only|tomcat6:stop|tomcat6:deploy|tomcat6:undeploy"
|
||||
local plugin_goals_tomcat7="tomcat7:help|tomcat7:run|tomcat7:run-war|tomcat7:run-war-only|tomcat7:deploy"
|
||||
local plugin_goals_tomcat="tomcat:help|tomcat:start|tomcat:stop|tomcat:deploy|tomcat:undeploy"
|
||||
local plugin_goals_liberty="liberty:create-server|liberty:start-server|liberty:stop-server|liberty:run-server|liberty:deploy|liberty:undeploy|liberty:java-dump-server|liberty:dump-server|liberty:package-server"
|
||||
local plugin_goals_versions="versions:display-dependency-updates|versions:display-plugin-updates|versions:display-property-updates|versions:update-parent|versions:update-properties|versions:update-child-modules|versions:lock-snapshots|versions:unlock-snapshots|versions:resolve-ranges|versions:set|versions:use-releases|versions:use-next-releases|versions:use-latest-releases|versions:use-next-snapshots|versions:use-latest-snapshots|versions:use-next-versions|versions:use-latest-versions|versions:commit|versions:revert"
|
||||
local plugin_goals_vertx="vertx:init|vertx:runMod|vertx:pullInDeps|vertx:fatJar"
|
||||
local plugin_goals_war="war:war|war:exploded|war:inplace|war:manifest"
|
||||
local plugin_goals_spring_boot="spring-boot:run|spring-boot:repackage"
|
||||
local plugin_goals_jgitflow="jgitflow:feature-start|jgitflow:feature-finish|jgitflow:release-start|jgitflow:release-finish|jgitflow:hotfix-start|jgitflow:hotfix-finish|jgitflow:build-number"
|
||||
local plugin_goals_wildfly="wildfly:add-resource|wildfly:deploy|wildfly:deploy-only|wildfly:deploy-artifact|wildfly:redeploy|wildfly:redeploy-only|wildfly:undeploy|wildfly:undeploy-artifact|wildfly:run|wildfly:start|wildfly:shutdown|wildfly:execute-commands"
|
||||
|
||||
## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace
|
||||
local common_plugins=`compgen -v | grep "^plugin_goals_.*" | sed 's/plugin_goals_//g' | tr '_' '-' | tr '\n' '|'`
|
||||
## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace
|
||||
local common_plugins=`compgen -v | grep "^plugin_goals_.*" | sed 's/plugin_goals_//g' | tr '_' '-' | tr '\n' '|'`
|
||||
|
||||
local options="-Dmaven.test.skip=true|-DskipTests|-DskipITs|-Dtest|-Dit.test|-DfailIfNoTests|-Dmaven.surefire.debug|-DenableCiProfile|-Dpmd.skip=true|-Dcheckstyle.skip=true|-Dtycho.mode=maven|-Dmaven.javadoc.skip=true|-Dgwt.compiler.skip|-Dcobertura.skip=true|-Dfindbugs.skip=true||-DperformRelease=true|-Dgpg.skip=true|-DforkCount"
|
||||
local options="-Dmaven.test.skip=true|-DskipTests|-DskipITs|-Dtest|-Dit.test|-DfailIfNoTests|-Dmaven.surefire.debug|-DenableCiProfile|-Dpmd.skip=true|-Dcheckstyle.skip=true|-Dtycho.mode=maven|-Dmaven.javadoc.skip=true|-Dgwt.compiler.skip|-Dcobertura.skip=true|-Dfindbugs.skip=true||-DperformRelease=true|-Dgpg.skip=true|-DforkCount"
|
||||
|
||||
local profile_settings=`[ -e ~/.m2/settings.xml ] && grep -e "<profile>" -A 1 ~/.m2/settings.xml | grep -e "<id>.*</id>" | sed 's/.*<id>//' | sed 's/<\/id>.*//g' | tr '\n' '|' `
|
||||
local profile_settings=`[ -e ~/.m2/settings.xml ] && grep -e "<profile>" -A 1 ~/.m2/settings.xml | grep -e "<id>.*</id>" | sed 's/.*<id>//' | sed 's/<\/id>.*//g' | tr '\n' '|' `
|
||||
|
||||
local profiles="${profile_settings}|"
|
||||
for item in ${POM_HIERARCHY[*]}
|
||||
do
|
||||
local profile_pom=`[ -e $item ] && grep -e "<profile>" -A 1 $item | grep -e "<id>.*</id>" | sed 's/.*<id>//' | sed 's/<\/id>.*//g' | tr '\n' '|' `
|
||||
local profiles="${profiles}|${profile_pom}"
|
||||
done
|
||||
local profiles="${profile_settings}|"
|
||||
for item in ${POM_HIERARCHY[*]}
|
||||
do
|
||||
local profile_pom=`[ -e $item ] && grep -e "<profile>" -A 1 $item | grep -e "<id>.*</id>" | sed 's/.*<id>//' | sed 's/<\/id>.*//g' | tr '\n' '|' `
|
||||
local profiles="${profiles}|${profile_pom}"
|
||||
done
|
||||
|
||||
local IFS=$'|\n'
|
||||
local IFS=$'|\n'
|
||||
|
||||
if [[ ${cur} == -D* ]] ; then
|
||||
COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) )
|
||||
|
||||
elif [[ ${prev} == -P ]] ; then
|
||||
if [[ ${cur} == *,* ]] ; then
|
||||
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) )
|
||||
else
|
||||
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -- ${cur}) )
|
||||
fi
|
||||
|
||||
elif [[ ${cur} == --* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${long_opts}" -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${cur} == -* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${prev} == -pl ]] ; then
|
||||
if [[ ${cur} == *,* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -P "${cur%,*}," -- ${cur##*,}) )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -- ${cur}) )
|
||||
fi
|
||||
|
||||
elif [[ ${prev} == -rf || ${prev} == --resume-from ]] ; then
|
||||
COMPREPLY=( $(compgen -d -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${cur} == *:* ]] ; then
|
||||
local plugin
|
||||
for plugin in $common_plugins; do
|
||||
if [[ ${cur} == ${plugin}:* ]]; then
|
||||
## note that here is an 'unreplace', see the comment at common_plugins
|
||||
var_name="plugin_goals_${plugin//-/_}"
|
||||
COMPREPLY=( $(compgen -W "${!var_name}" -S ' ' -- ${cur}) )
|
||||
fi
|
||||
done
|
||||
if [[ ${cur} == -D* ]] ; then
|
||||
COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) )
|
||||
|
||||
elif [[ ${prev} == -P ]] ; then
|
||||
if [[ ${cur} == *,* ]] ; then
|
||||
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) )
|
||||
else
|
||||
if echo "${common_lifecycle_phases}" | tr '|' '\n' | grep -q -e "^${cur}" ; then
|
||||
COMPREPLY=( $(compgen -S ' ' -W "${common_lifecycle_phases}" -- ${cur}) )
|
||||
elif echo "${common_plugins}" | tr '|' '\n' | grep -q -e "^${cur}"; then
|
||||
COMPREPLY=( $(compgen -S ':' -W "${common_plugins}" -- ${cur}) )
|
||||
fi
|
||||
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -- ${cur}) )
|
||||
fi
|
||||
|
||||
__ltrim_colon_completions "$cur"
|
||||
elif [[ ${cur} == --* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${long_opts}" -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${cur} == -* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${prev} == -pl ]] ; then
|
||||
if [[ ${cur} == *,* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -P "${cur%,*}," -- ${cur##*,}) )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -- ${cur}) )
|
||||
fi
|
||||
|
||||
elif [[ ${prev} == -rf || ${prev} == --resume-from ]] ; then
|
||||
COMPREPLY=( $(compgen -d -S ' ' -- ${cur}) )
|
||||
|
||||
elif [[ ${cur} == *:* ]] ; then
|
||||
local plugin
|
||||
for plugin in $common_plugins; do
|
||||
if [[ ${cur} == ${plugin}:* ]]; then
|
||||
## note that here is an 'unreplace', see the comment at common_plugins
|
||||
var_name="plugin_goals_${plugin//-/_}"
|
||||
COMPREPLY=( $(compgen -W "${!var_name}" -S ' ' -- ${cur}) )
|
||||
fi
|
||||
done
|
||||
|
||||
else
|
||||
if echo "${common_lifecycle_phases}" | tr '|' '\n' | grep -q -e "^${cur}" ; then
|
||||
COMPREPLY=( $(compgen -S ' ' -W "${common_lifecycle_phases}" -- ${cur}) )
|
||||
elif echo "${common_plugins}" | tr '|' '\n' | grep -q -e "^${cur}"; then
|
||||
COMPREPLY=( $(compgen -S ':' -W "${common_plugins}" -- ${cur}) )
|
||||
fi
|
||||
fi
|
||||
|
||||
__ltrim_colon_completions "$cur"
|
||||
}
|
||||
|
||||
complete -o default -F _mvn -o nospace mvn
|
||||
|
@ -14,113 +14,112 @@
|
||||
|
||||
|
||||
function _salt_get_grains {
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
fi
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
fi
|
||||
}
|
||||
|
||||
function _salt_get_grain_values {
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
fi
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function _salt {
|
||||
local cur prev opts pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
local cur prev opts pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
|
||||
opts="-h --help -d --doc --documentation --version --versions-report -c \
|
||||
--config-dir= -v --verbose -t --timeout= -s --static -b --batch= \
|
||||
--batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \
|
||||
--nodegroup -R --range -C --compound -I --pillar \
|
||||
--return= -a --auth= --eauth= --extended-auth= -T --make-token -S \
|
||||
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
|
||||
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
opts="-h --help -d --doc --documentation --version --versions-report -c \
|
||||
--config-dir= -v --verbose -t --timeout= -s --static -b --batch= \
|
||||
--batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \
|
||||
--nodegroup -R --range -C --compound -I --pillar \
|
||||
--return= -a --auth= --eauth= --extended-auth= -T --make-token -S \
|
||||
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
|
||||
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 2 special cases for filling up grain values
|
||||
case "${pprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
# 2 special cases for filling up grain values
|
||||
case "${pprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${cur}" = ":" ]; then
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$prev")'))
|
||||
return 0
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$prev")'))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case "${ppprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${prev}" = ":" ]; then
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$pprev")' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
esac
|
||||
case "${ppprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${prev}" = ":" ]; then
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$pprev")' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
salt)
|
||||
COMPREPLY=($(compgen -W "\'*\' \$opts \$(salt-key --no-color -l acc)" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W '$(salt-key --no-color -l acc)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
COMPREPLY=() # TODO: finish this one? how?
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-b|--batch|--batch-size)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 50 60 70 80 90 100 120 150 200"))
|
||||
return 0
|
||||
;;
|
||||
-N|--nodegroup)
|
||||
local MASTER_CONFIG='/etc/salt/master'
|
||||
local all=$(awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' < "$MASTER_CONFIG")
|
||||
COMPREPLY=($(compgen -W '$all' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
local _salt_coms=$(salt '*' --timeout 2 --out=txt -- sys.list_functions | sed 's/^.*\[//' | tr -d ",']" )
|
||||
local all="${opts} ${_salt_coms}"
|
||||
case "${prev}" in
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
salt)
|
||||
COMPREPLY=($(compgen -W "\'*\' \$opts \$(salt-key --no-color -l acc)" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W '$(salt-key --no-color -l acc)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
COMPREPLY=() # TODO: finish this one? how?
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-b|--batch|--batch-size)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 50 60 70 80 90 100 120 150 200"))
|
||||
return 0
|
||||
;;
|
||||
-N|--nodegroup)
|
||||
local MASTER_CONFIG='/etc/salt/master'
|
||||
local all=$(awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' < "$MASTER_CONFIG")
|
||||
COMPREPLY=($(compgen -W '$all' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
local _salt_coms=$(salt '*' --timeout 2 --out=txt -- sys.list_functions | sed 's/^.*\[//' | tr -d ",']" )
|
||||
local all="${opts} ${_salt_coms}"
|
||||
COMPREPLY=($(compgen -W '$all' -- "$cur"))
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -129,202 +128,202 @@ complete -F _salt salt
|
||||
|
||||
|
||||
function _saltkey {
|
||||
local cur prev opts prev pprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-c --config-dir= -h --help --version --versions-report -q --quiet \
|
||||
-y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \
|
||||
-l --list= -L --list-all -a --accept= -A --accept-all \
|
||||
-r --reject= -R --reject-all -p --print= -P --print-all \
|
||||
-d --delete= -D --delete-all -f --finger= -F --finger-all \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
-a|--accept)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-r|--reject)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-d|--delete)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--keysize)
|
||||
COMPREPLY=($(compgen -W "2048 3072 4096 5120 6144" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--gen-keys)
|
||||
return 0
|
||||
;;
|
||||
--gen-keys-dir)
|
||||
COMPREPLY=($(compgen -d -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-p|--print)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-l|--list)
|
||||
COMPREPLY=($(compgen -W "pre un acc accepted unaccepted rej rejected all" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--accept-all)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
local cur prev opts prev pprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-c --config-dir= -h --help --version --versions-report -q --quiet \
|
||||
-y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \
|
||||
-l --list= -L --list-all -a --accept= -A --accept-all \
|
||||
-r --reject= -R --reject-all -p --print= -P --print-all \
|
||||
-d --delete= -D --delete-all -f --finger= -F --finger-all \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
-a|--accept)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-r|--reject)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-d|--delete)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--keysize)
|
||||
COMPREPLY=($(compgen -W "2048 3072 4096 5120 6144" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--gen-keys)
|
||||
return 0
|
||||
;;
|
||||
--gen-keys-dir)
|
||||
COMPREPLY=($(compgen -d -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-p|--print)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-l|--list)
|
||||
COMPREPLY=($(compgen -W "pre un acc accepted unaccepted rej rejected all" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
--accept-all)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltkey salt-key
|
||||
|
||||
function _saltcall {
|
||||
local cur prev opts pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-h --help -d --doc --documentation --version --versions-report \
|
||||
-m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
-m|--module-dirs)
|
||||
COMPREPLY=($(compgen -d -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-l|--log-level)
|
||||
COMPREPLY=($(compgen -W "info none garbage trace warning error debug" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-g|grains)
|
||||
return 0
|
||||
;;
|
||||
salt-call)
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
local _salt_coms=$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']")
|
||||
COMPREPLY=($(compgen -W '$opts $_salt_coms' -- "$cur"))
|
||||
local cur prev opts pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-h --help -d --doc --documentation --version --versions-report \
|
||||
-m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
-m|--module-dirs)
|
||||
COMPREPLY=($(compgen -d -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-l|--log-level)
|
||||
COMPREPLY=($(compgen -W "info none garbage trace warning error debug" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-g|grains)
|
||||
return 0
|
||||
;;
|
||||
salt-call)
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
local _salt_coms=$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']")
|
||||
COMPREPLY=($(compgen -W '$opts $_salt_coms' -- "$cur"))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltcall salt-call
|
||||
|
||||
|
||||
function _saltcp {
|
||||
local cur prev opts target prefpart postpart helper filt pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-t --timeout= -s --static -b --batch= --batch-size= \
|
||||
-h --help --version --versions-report -c --config-dir= \
|
||||
-E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \
|
||||
-R --range -C --compound -I --pillar \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
local cur prev opts target prefpart postpart helper filt pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-t --timeout= -s --static -b --batch= --batch-size= \
|
||||
-h --help --version --versions-report -c --config-dir= \
|
||||
-E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \
|
||||
-R --range -C --compound -I --pillar \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev=${pprev}
|
||||
fi
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev=${pprev}
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
salt-cp)
|
||||
COMPREPLY=($(compgen -W '$opts $(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
# those numbers are just a hint
|
||||
COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-L|--list)
|
||||
# IMPROVEMENTS ARE WELCOME
|
||||
prefpart="${cur%,*},"
|
||||
postpart=${cur##*,}
|
||||
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
|
||||
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
|
||||
COMPREPLY=($(compgen -W '"${helper[@]}"' -- "$cur"))
|
||||
case ${prev} in
|
||||
salt-cp)
|
||||
COMPREPLY=($(compgen -W '$opts $(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
# those numbers are just a hint
|
||||
COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
-L|--list)
|
||||
# IMPROVEMENTS ARE WELCOME
|
||||
prefpart="${cur%,*},"
|
||||
postpart=${cur##*,}
|
||||
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
|
||||
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
|
||||
COMPREPLY=($(compgen -W '"${helper[@]}"' -- "$cur"))
|
||||
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
# FIXME
|
||||
-R|--range)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
# FIXME
|
||||
-R|--range)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# default is using opts:
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
# default is using opts:
|
||||
COMPREPLY=($(compgen -W '$opts' -- "$cur"))
|
||||
}
|
||||
|
||||
complete -F _saltcp salt-cp
|
||||
|
@ -32,32 +32,32 @@ _omb_completion_sdkman()
|
||||
COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- "$cur") )
|
||||
elif ((COMP_CWORD == 2)); then
|
||||
case ${COMP_WORDS[COMP_CWORD-1]} in
|
||||
"install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" )
|
||||
local candidates
|
||||
candidates=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
|
||||
COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
|
||||
;;
|
||||
"offline" )
|
||||
COMPREPLY=( $(compgen -W "enable disable" -- "$cur") )
|
||||
;;
|
||||
"selfupdate" )
|
||||
COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- "$cur") )
|
||||
;;
|
||||
"flush" )
|
||||
COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- "$cur") )
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
"install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" )
|
||||
local candidates
|
||||
candidates=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
|
||||
COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
|
||||
;;
|
||||
"offline" )
|
||||
COMPREPLY=( $(compgen -W "enable disable" -- "$cur") )
|
||||
;;
|
||||
"selfupdate" )
|
||||
COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- "$cur") )
|
||||
;;
|
||||
"flush" )
|
||||
COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- "$cur") )
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
elif ((COMP_CWORD == 3)); then
|
||||
case ${COMP_WORDS[COMP_CWORD-2]} in
|
||||
"install" | "uninstall" | "rm" | "use" | "default" )
|
||||
local candidate_versions
|
||||
_omb_completion_sdkman__candidate_versions "${COMP_WORDS[COMP_CWORD-1]}"
|
||||
COMPREPLY=( $(compgen -W "$candidate_versions" -- "$cur") )
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
"install" | "uninstall" | "rm" | "use" | "default" )
|
||||
local candidate_versions
|
||||
_omb_completion_sdkman__candidate_versions "${COMP_WORDS[COMP_CWORD-1]}"
|
||||
COMPREPLY=( $(compgen -W "$candidate_versions" -- "$cur") )
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
@ -7,180 +7,179 @@
|
||||
|
||||
_tmux_expand ()
|
||||
{
|
||||
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
|
||||
if [[ "$cur" == \~*/* ]]; then
|
||||
eval cur=$cur;
|
||||
else
|
||||
if [[ "$cur" == \~* ]]; then
|
||||
cur=${cur#\~};
|
||||
COMPREPLY=($( compgen -P '~' -u $cur ));
|
||||
return ${#COMPREPLY[@]};
|
||||
fi;
|
||||
fi
|
||||
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
|
||||
if [[ "$cur" == \~*/* ]]; then
|
||||
eval cur=$cur;
|
||||
else
|
||||
if [[ "$cur" == \~* ]]; then
|
||||
cur=${cur#\~};
|
||||
COMPREPLY=($( compgen -P '~' -u $cur ));
|
||||
return ${#COMPREPLY[@]};
|
||||
fi;
|
||||
fi
|
||||
}
|
||||
|
||||
_tmux_filedir ()
|
||||
{
|
||||
local IFS='
|
||||
local IFS='
|
||||
';
|
||||
_tmux_expand || return 0;
|
||||
if [ "$1" = -d ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
|
||||
return 0;
|
||||
fi;
|
||||
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
|
||||
_tmux_expand || return 0;
|
||||
if [ "$1" = -d ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
|
||||
return 0;
|
||||
fi;
|
||||
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
|
||||
}
|
||||
|
||||
function _tmux_complete_client() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_session() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_window() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
|
||||
local sessions
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
|
||||
local sessions
|
||||
|
||||
sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')"
|
||||
if [[ -n "${session_name}" ]]; then
|
||||
sessions="${sessions}
|
||||
sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')"
|
||||
if [[ -n "${session_name}" ]]; then
|
||||
sessions="${sessions}
|
||||
$(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')"
|
||||
fi
|
||||
cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
|
||||
sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
|
||||
fi
|
||||
cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
|
||||
sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
|
||||
}
|
||||
|
||||
function _tmux {
|
||||
local cur prev
|
||||
local i cmd cmd_index option option_index
|
||||
local opts=""
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur prev
|
||||
local i cmd cmd_index option option_index
|
||||
local opts=""
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ ${prev} == -f ]; then
|
||||
_tmux_filedir
|
||||
else
|
||||
if [ ${prev} == -f ]; then
|
||||
_tmux_filedir
|
||||
else
|
||||
# Search for the command
|
||||
local skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
cmd="${COMP_WORDS[i]}"
|
||||
cmd_index=${i}
|
||||
break
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
cmd="${COMP_WORDS[i]}"
|
||||
cmd_index=${i}
|
||||
break
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Search for the last option command
|
||||
skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} == -* ]]; then
|
||||
option="${COMP_WORDS[i]}"
|
||||
option_index=${i}
|
||||
if [[ ${COMP_WORDS[i]} == -- ]]; then
|
||||
break;
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} == -* ]]; then
|
||||
option="${COMP_WORDS[i]}"
|
||||
option_index=${i}
|
||||
if [[ ${COMP_WORDS[i]} == -- ]]; then
|
||||
break;
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $COMP_CWORD -le $cmd_index ]]; then
|
||||
# The user has not specified a command yet
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") )
|
||||
# The user has not specified a command yet
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") )
|
||||
else
|
||||
case ${cmd} in
|
||||
attach-session|attach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
detach-client|detach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-client|lockc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-session|locks)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
new-session|new)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
-[n|d|s]) options="-d -n -s -t --" ;;
|
||||
*)
|
||||
if [[ ${COMP_WORDS[option_index]} == -- ]]; then
|
||||
_command_offset ${option_index}
|
||||
else
|
||||
options="-d -n -s -t --"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
refresh-client|refresh)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
rename-session|rename)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
source-file|source) _tmux_filedir ;;
|
||||
has-session|has|kill-session)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
suspend-client|suspendc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
switch-client|switchc)
|
||||
case "$prev" in
|
||||
-c) _tmux_complete_client "${cur}" ;;
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-l -n -p -c -t" ;;
|
||||
esac ;;
|
||||
case ${cmd} in
|
||||
attach-session|attach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
detach-client|detach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-client|lockc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-session|locks)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
new-session|new)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
-[n|d|s]) options="-d -n -s -t --" ;;
|
||||
*)
|
||||
if [[ ${COMP_WORDS[option_index]} == -- ]]; then
|
||||
_command_offset ${option_index}
|
||||
else
|
||||
options="-d -n -s -t --"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
refresh-client|refresh)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
rename-session|rename)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
source-file|source) _tmux_filedir ;;
|
||||
has-session|has|kill-session)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
suspend-client|suspendc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
switch-client|switchc)
|
||||
case "$prev" in
|
||||
-c) _tmux_complete_client "${cur}" ;;
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-l -n -p -c -t" ;;
|
||||
esac ;;
|
||||
|
||||
send-keys|send)
|
||||
case "$option" in
|
||||
-t) _tmux_complete_window "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
esac # case ${cmd}
|
||||
fi # command specified
|
||||
fi # not -f
|
||||
send-keys|send)
|
||||
case "$option" in
|
||||
-t) _tmux_complete_window "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
esac # case ${cmd}
|
||||
fi # command specified
|
||||
fi # not -f
|
||||
|
||||
if [[ -n "${options}" ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
|
||||
fi
|
||||
|
||||
return 0
|
||||
if [[ -n "${options}" ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -F _tmux tmux
|
||||
|
||||
|
@ -24,124 +24,124 @@
|
||||
|
||||
|
||||
function __pwdln {
|
||||
pwdmod="${PWD}/"
|
||||
itr=0
|
||||
until [[ -z "$pwdmod" ]];do
|
||||
itr=$(($itr+1))
|
||||
pwdmod="${pwdmod#*/}"
|
||||
done
|
||||
echo -n $(($itr-1))
|
||||
pwdmod="${PWD}/"
|
||||
itr=0
|
||||
until [[ -z "$pwdmod" ]];do
|
||||
itr=$(($itr+1))
|
||||
pwdmod="${pwdmod#*/}"
|
||||
done
|
||||
echo -n $(($itr-1))
|
||||
}
|
||||
|
||||
function __vagrantinvestigate {
|
||||
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
|
||||
echo "${PWD}/.vagrant"
|
||||
return 0
|
||||
else
|
||||
pwdmod2="${PWD}"
|
||||
for (( i=2; i<=$(__pwdln); i++ ));do
|
||||
pwdmod2="${pwdmod2%/*}"
|
||||
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ];then
|
||||
echo "${pwdmod2}/.vagrant"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 1
|
||||
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
|
||||
echo "${PWD}/.vagrant"
|
||||
return 0
|
||||
else
|
||||
pwdmod2="${PWD}"
|
||||
for (( i=2; i<=$(__pwdln); i++ ));do
|
||||
pwdmod2="${pwdmod2%/*}"
|
||||
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ];then
|
||||
echo "${pwdmod2}/.vagrant"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function _vagrant {
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
commands="snapshot box connect destroy docker-logs docker-run global-status halt help init list-commands login package plugin provision rdp reload resume rsync rsync-auto share ssh ssh-config status suspend up version"
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
commands="snapshot box connect destroy docker-logs docker-run global-status halt help init list-commands login package plugin provision rdp reload resume rsync rsync-auto share ssh ssh-config status suspend up version"
|
||||
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
"init")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"up")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -d $vagrant_state_file ]]
|
||||
then
|
||||
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||
fi
|
||||
local up_commands="--no-provision"
|
||||
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -f $vagrant_state_file ]]
|
||||
then
|
||||
running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
||||
else
|
||||
running_vm_list=$(find "$vagrant_state_file" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"box")
|
||||
box_commands="add help list remove repackage"
|
||||
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"plugin")
|
||||
plugin_commands="install license list uninstall update"
|
||||
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"help")
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"snapshot")
|
||||
snapshot_commands="back delete go list take"
|
||||
COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
"init")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"up")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -d $vagrant_state_file ]]
|
||||
then
|
||||
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||
fi
|
||||
local up_commands="--no-provision"
|
||||
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -f $vagrant_state_file ]]
|
||||
then
|
||||
running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
||||
else
|
||||
running_vm_list=$(find "$vagrant_state_file" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"box")
|
||||
box_commands="add help list remove repackage"
|
||||
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"plugin")
|
||||
plugin_commands="install license list uninstall update"
|
||||
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"help")
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"snapshot")
|
||||
snapshot_commands="back delete go list take"
|
||||
COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 3 ]
|
||||
then
|
||||
action="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "$action" in
|
||||
"up")
|
||||
if [ "$prev" == "--no-provision" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"box")
|
||||
case "$prev" in
|
||||
"remove"|"repackage")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
;;
|
||||
"snapshot")
|
||||
if [ "$prev" == "go" ]; then
|
||||
local snapshot_list=$(vagrant snapshot list | awk '/Name:/ { print $2 }')
|
||||
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
if [ $COMP_CWORD == 3 ]
|
||||
then
|
||||
action="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "$action" in
|
||||
"up")
|
||||
if [ "$prev" == "--no-provision" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"box")
|
||||
case "$prev" in
|
||||
"remove"|"repackage")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
"snapshot")
|
||||
if [ "$prev" == "go" ]; then
|
||||
local snapshot_list=$(vagrant snapshot list | awk '/Name:/ { print $2 }')
|
||||
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
complete -F _vagrant vagrant
|
||||
|
@ -1,85 +1,85 @@
|
||||
#! bash oh-my-bash.module
|
||||
|
||||
function _vboxmanage_realopts {
|
||||
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
|
||||
echo " "
|
||||
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
|
||||
echo " "
|
||||
}
|
||||
|
||||
function __vboxmanage_startvm {
|
||||
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
|
||||
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
|
||||
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
|
||||
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
|
||||
|
||||
AVAILABLE=""
|
||||
for VM in $TOTAL; do
|
||||
MATCH=0;
|
||||
for RUN in $RUNNING "x"; do
|
||||
if [ "$VM" == "$RUN" ]; then
|
||||
MATCH=1
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
|
||||
AVAILABLE=""
|
||||
for VM in $TOTAL; do
|
||||
MATCH=0;
|
||||
for RUN in $RUNNING "x"; do
|
||||
if [ "$VM" == "$RUN" ]; then
|
||||
MATCH=1
|
||||
fi
|
||||
done
|
||||
echo $AVAILABLE
|
||||
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
|
||||
done
|
||||
echo $AVAILABLE
|
||||
}
|
||||
|
||||
function __vboxmanage_list {
|
||||
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
|
||||
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
|
||||
|
||||
PRUNED=""
|
||||
if [ "$1" == "long" ]; then
|
||||
for WORD in $INPUT; do
|
||||
[ "$WORD" == "-l" ] && continue;
|
||||
[ "$WORD" == "--long" ] && continue;
|
||||
PRUNED=""
|
||||
if [ "$1" == "long" ]; then
|
||||
for WORD in $INPUT; do
|
||||
[ "$WORD" == "-l" ] && continue;
|
||||
[ "$WORD" == "--long" ] && continue;
|
||||
|
||||
PRUNED="$PRUNED $WORD"
|
||||
done
|
||||
else
|
||||
PRUNED=$INPUT
|
||||
fi
|
||||
PRUNED="$PRUNED $WORD"
|
||||
done
|
||||
else
|
||||
PRUNED=$INPUT
|
||||
fi
|
||||
|
||||
echo $PRUNED
|
||||
echo $PRUNED
|
||||
}
|
||||
|
||||
|
||||
function __vboxmanage_list_vms {
|
||||
VMS=""
|
||||
if [ "x$1" == "x" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
VMS=""
|
||||
if [ "x$1" == "x" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
echo $VMS
|
||||
}
|
||||
|
||||
function __vboxmanage_list_runningvms {
|
||||
VMS=""
|
||||
if [ "$1" == "" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
VMS=""
|
||||
if [ "$1" == "" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
}
|
||||
|
||||
function __vboxmanage_controlvm {
|
||||
echo "pause resume reset poweroff savestate acpipowerbutton"
|
||||
echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
|
||||
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
|
||||
echo "vrdeproperty vrdevideochannelquality setvideomodehint"
|
||||
echo "screenshotpng setcredentials teleport plugcpu unplugcpu"
|
||||
echo "cpuexecutioncap"
|
||||
echo "pause resume reset poweroff savestate acpipowerbutton"
|
||||
echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
|
||||
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
|
||||
echo "vrdeproperty vrdevideochannelquality setvideomodehint"
|
||||
echo "screenshotpng setcredentials teleport plugcpu unplugcpu"
|
||||
echo "cpuexecutioncap"
|
||||
|
||||
# setlinkstate<1-N>
|
||||
# nic<1-N> null|nat|bridged|intnet|hostonly|generic
|
||||
@ -94,129 +94,129 @@ function __vboxmanage_controlvm {
|
||||
}
|
||||
|
||||
function __vboxmanage_default {
|
||||
realopts=$(_vboxmanage_realopts)
|
||||
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
|
||||
pruned=""
|
||||
realopts=$(_vboxmanage_realopts)
|
||||
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
|
||||
pruned=""
|
||||
|
||||
# echo ""
|
||||
# echo "DEBUG: cur: $cur, prev: $prev"
|
||||
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
|
||||
case ${cur} in
|
||||
-*)
|
||||
echo $opts
|
||||
# COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac;
|
||||
|
||||
for WORD in $opts; do
|
||||
MATCH=0
|
||||
for OPT in ${COMP_WORDS[@]}; do
|
||||
# opts=$(echo ${opts} | grep -v $OPT);
|
||||
if [ "$OPT" == "$WORD" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 1 )) && continue;
|
||||
pruned="$pruned $WORD"
|
||||
|
||||
done
|
||||
|
||||
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
|
||||
echo $pruned
|
||||
# echo ""
|
||||
# echo "DEBUG: cur: $cur, prev: $prev"
|
||||
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
|
||||
case ${cur} in
|
||||
-*)
|
||||
echo $opts
|
||||
# COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac;
|
||||
|
||||
for WORD in $opts; do
|
||||
MATCH=0
|
||||
for OPT in ${COMP_WORDS[@]}; do
|
||||
# opts=$(echo ${opts} | grep -v $OPT);
|
||||
if [ "$OPT" == "$WORD" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 1 )) && continue;
|
||||
pruned="$pruned $WORD"
|
||||
|
||||
done
|
||||
|
||||
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
|
||||
echo $pruned
|
||||
return 0
|
||||
}
|
||||
|
||||
function _vboxmanage {
|
||||
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
|
||||
local cur p1 p2 p3 p4 opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
|
||||
local cur p1 p2 p3 p4 opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# echo "cur: |$cur|"
|
||||
# echo "prev: |$prev|"
|
||||
# echo "cur: |$cur|"
|
||||
# echo "prev: |$prev|"
|
||||
|
||||
# In case current is complete command
|
||||
case $cur in
|
||||
startvm|list|controlvm)
|
||||
COMPREPLY=($(compgen -W "$cur "))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
# In case current is complete command
|
||||
case $cur in
|
||||
startvm|list|controlvm)
|
||||
COMPREPLY=($(compgen -W "$cur "))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case $prev in
|
||||
-v|--version)
|
||||
return 0
|
||||
;;
|
||||
case $prev in
|
||||
-v|--version)
|
||||
return 0
|
||||
;;
|
||||
|
||||
-l|--long)
|
||||
opts=$(__vboxmanage_list "long")
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
startvm|list)
|
||||
opts=$(__vboxmanage_$prev)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--type)
|
||||
COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
gui|headless)
|
||||
# Done. no more completion possible
|
||||
return 0
|
||||
;;
|
||||
vboxmanage|-q|--nologo)
|
||||
# echo "Got vboxmanage"
|
||||
opts=$(__vboxmanage_default)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_list_vms)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
-l|--long)
|
||||
opts=$(__vboxmanage_list "long")
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
startvm|list)
|
||||
opts=$(__vboxmanage_$prev)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--type)
|
||||
COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
gui|headless)
|
||||
# Done. no more completion possible
|
||||
return 0
|
||||
;;
|
||||
vboxmanage|-q|--nologo)
|
||||
# echo "Got vboxmanage"
|
||||
opts=$(__vboxmanage_default)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_list_vms)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
for VM in $(__vboxmanage_list_vms); do
|
||||
if [ "$VM" == "$prev" ]; then
|
||||
pprev=${COMP_WORDS[COMP_CWORD-2]}
|
||||
# echo "previous: $pprev"
|
||||
case $pprev in
|
||||
startvm)
|
||||
opts="--type"
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_controlvm)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0;
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
for VM in $(__vboxmanage_list_vms); do
|
||||
if [ "$VM" == "$prev" ]; then
|
||||
pprev=${COMP_WORDS[COMP_CWORD-2]}
|
||||
# echo "previous: $pprev"
|
||||
case $pprev in
|
||||
startvm)
|
||||
opts="--type"
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_controlvm)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0;
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
# echo "Got to end withoug completion"
|
||||
# echo "Got to end withoug completion"
|
||||
}
|
||||
complete -F _vboxmanage vboxmanage
|
||||
|
Loading…
Reference in New Issue
Block a user