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:
Koichi Murase 2024-08-15 21:39:22 +09:00
parent 1a57a3f113
commit 7ddbf0b541
12 changed files with 1859 additions and 1863 deletions

View File

@ -7,141 +7,140 @@
# #
# Version 1.0 (2006-11-08) # Version 1.0 (2006-11-08)
_defaults_domains() _defaults_domains()
{ {
local cur local cur
COMPREPLY=() COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" ) local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" )
local IFS=$'\n' local IFS=$'\n'
COMPREPLY=( $domains ) COMPREPLY=( $domains )
if [[ $( echo '-app' | grep "^$cur" ) ]]; then if [[ $( echo '-app' | grep "^$cur" ) ]]; then
COMPREPLY[${#COMPREPLY[@]}]="-app" COMPREPLY[${#COMPREPLY[@]}]="-app"
fi fi
return 0 return 0
} }
_defaults() _defaults()
{ {
local cur prev host_opts cmds cmd domain keys key_index local cur prev host_opts cmds cmd domain keys key_index
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
host_opts='-currentHost -host' host_opts='-currentHost -host'
cmds='read read-type write rename delete domains find help' 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
if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=( $( compgen -W "$host_opts $cmds" -- $cur ) )
return 0 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 complete -F _defaults -o default defaults

View File

@ -38,17 +38,17 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-s) -s)
unset s unset s
;; ;;
*) *)
for sh in $shells; do for sh in $shells; do
if [ "$sh" = "$i" ]; then if [ "$sh" = "$i" ]; then
unset shells unset shells
break break
fi fi
done done
;; ;;
esac esac
((c++)) ((c++))
done done
@ -65,16 +65,16 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-u) -u)
unset u unset u
;; ;;
*) *)
if [ -z "$repo" ]; then if [ -z "$repo" ]; then
repo=$i repo=$i
else else
subpage=$i subpage=$i
fi fi
;; ;;
esac esac
((c++)) ((c++))
done done
@ -82,14 +82,14 @@ EOF
__gitcomp "$u -- $(__hub_github_repos '\p')" __gitcomp "$u -- $(__hub_github_repos '\p')"
elif [ -z "$subpage" ]; then elif [ -z "$subpage" ]; then
case "$cur" in case "$cur" in
*/*) */*)
local pfx="${cur%/*}" cur_="${cur#*/}" local pfx="${cur%/*}" cur_="${cur#*/}"
local subpages_var="subpages_$pfx" local subpages_var="subpages_$pfx"
__gitcomp "${!subpages_var}" "$pfx/" "$cur_" __gitcomp "${!subpages_var}" "$pfx/" "$cur_"
;; ;;
*) *)
__gitcomp "$u ${subpages_}" __gitcomp "$u ${subpages_}"
;; ;;
esac esac
else else
__gitcomp "$u" __gitcomp "$u"
@ -102,26 +102,26 @@ EOF
while [ $c -gt 1 ]; do while [ $c -gt 1 ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-u) -u)
unset u unset u
;; ;;
*) *)
if [ -z "$rev" ]; then if [ -z "$rev" ]; then
# Even though the logic below is able to complete both user/repo # Even though the logic below is able to complete both user/repo
# and revision in the right place, when there is only one argument # and revision in the right place, when there is only one argument
# (other than -u) in the command, that argument will be taken as # (other than -u) in the command, that argument will be taken as
# revision. For example: # revision. For example:
# $ hub compare -u upstream # $ hub compare -u upstream
# > https://github.com/USER/REPO/compare/upstream # > https://github.com/USER/REPO/compare/upstream
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
arg_repo=$i
else
rev=$i
fi
elif [ -z "$arg_repo" ]; then
arg_repo=$i arg_repo=$i
else
rev=$i
fi fi
;; elif [ -z "$arg_repo" ]; then
arg_repo=$i
fi
;;
esac esac
((c--)) ((c--))
done done
@ -163,20 +163,20 @@ EOF
local pfx cur_="$cur" local pfx cur_="$cur"
case "$cur_" in case "$cur_" in
*..*) *..*)
pfx="${cur_%%..*}..." pfx="${cur_%%..*}..."
cur_="${cur_##*..}" cur_="${cur_##*..}"
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
;; ;;
*) *)
if [ -z "${arg_repo}${rev}" ]; then if [ -z "${arg_repo}${rev}" ]; then
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
elif [ -z "$rev" ]; then elif [ -z "$rev" ]; then
__gitcomp "$u $(__hub_revlist $remote)" __gitcomp "$u $(__hub_revlist $remote)"
else else
__gitcomp "$u" __gitcomp "$u"
fi fi
;; ;;
esac esac
} }
@ -186,16 +186,16 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-d|-h) -d|-h)
((c++)) ((c++))
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
-p) -p)
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
*) *)
name=$i name=$i
;; ;;
esac esac
((c++)) ((c++))
done done
@ -203,12 +203,12 @@ EOF
repo=$(basename "$PWD") repo=$(basename "$PWD")
fi fi
case "$prev" in case "$prev" in
-d|-h) -d|-h)
COMPREPLY=() COMPREPLY=()
;; ;;
-p|*) -p|*)
__gitcomp "$repo $flags" __gitcomp "$repo $flags"
;; ;;
esac esac
} }
@ -218,9 +218,9 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
--no-remote) --no-remote)
unset remote unset remote
;; ;;
esac esac
((c++)) ((c++))
done done
@ -235,33 +235,33 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-m|-F|-i|-b|-h) -m|-F|-i|-b|-h)
((c++)) ((c++))
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
-f) -f)
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
esac esac
((c++)) ((c++))
done done
case "$prev" in case "$prev" in
-i) -i)
COMPREPLY=() COMPREPLY=()
;; ;;
-b|-h) -b|-h)
# (Doesn't seem to need this...) # (Doesn't seem to need this...)
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved # Uncomment the following line when 'owner/repo:[TAB]' misbehaved
#_get_comp_words_by_ref -n : cur #_get_comp_words_by_ref -n : cur
__gitcomp_nl "$(__hub_heads)" __gitcomp_nl "$(__hub_heads)"
# __ltrim_colon_completions "$cur" # __ltrim_colon_completions "$cur"
;; ;;
-F) -F)
COMPREPLY=( "$cur"* ) COMPREPLY=( "$cur"* )
;; ;;
-f|*) -f|*)
__gitcomp "$flags" __gitcomp "$flags"
;; ;;
esac esac
} }
@ -364,4 +364,3 @@ EOF
complete -o bashdefault -o default -o nospace -F _git gh 2>/dev/null \ complete -o bashdefault -o default -o nospace -F _git gh 2>/dev/null \
|| complete -o default -o nospace -F _git gh || complete -o default -o nospace -F _git gh
fi fi

View File

@ -50,461 +50,461 @@
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) # Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
__git_flow_config_file_options=" __git_flow_config_file_options="
--local --global --system --file= --local --global --system --file=
" "
_git_flow () _git_flow ()
{ {
local subcommands="init feature release hotfix support help version config finish delete publish rebase" local subcommands="init feature release hotfix support help version config finish delete publish rebase"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
init) init)
__git_flow_init __git_flow_init
return return
;; ;;
feature) feature)
__git_flow_feature __git_flow_feature
return return
;; ;;
release) release)
__git_flow_release __git_flow_release
return return
;; ;;
hotfix) hotfix)
__git_flow_hotfix __git_flow_hotfix
return return
;; ;;
support) support)
__git_flow_support __git_flow_support
return return
;; ;;
config) config)
__git_flow_config __git_flow_config
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_init () __git_flow_init ()
{ {
local subcommands="help" local subcommands="help"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
fi fi
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nodefaults --defaults --nodefaults --defaults
--noforce --force --noforce --force
$__git_flow_config_file_options $__git_flow_config_file_options
" "
return return
;; ;;
esac esac
} }
__git_flow_feature () __git_flow_feature ()
{ {
local subcommands="list start finish publish track diff rebase checkout pull help delete" local subcommands="list start finish publish track diff rebase checkout pull help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
pull) pull)
__gitcomp_nl "$(__git_remotes)" __gitcomp_nl "$(__git_remotes)"
return return
;; ;;
checkout) checkout)
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')" __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
return return
;; ;;
delete) delete)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--noforce --force --noforce --force
--noremote --remote --noremote --remote
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')" __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
return return
;; ;;
finish) finish)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
--norebase --rebase --norebase --rebase
--nopreserve-merges --preserve-merges --nopreserve-merges --preserve-merges
--nokeep --keep --nokeep --keep
--keepremote --keepremote
--keeplocal --keeplocal
--noforce_delete --force_delete --noforce_delete --force_delete
--nosquash --squash --nosquash --squash
--no-ff --no-ff
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')" __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
return return
;; ;;
diff) diff)
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')" __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
return return
;; ;;
rebase) rebase)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nointeractive --interactive --nointeractive --interactive
--nopreserve-merges --preserve-merges --nopreserve-merges --preserve-merges
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')" __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
return return
;; ;;
publish) publish)
__gitcomp_nl "$(__git_flow_list_branches 'feature')" __gitcomp_nl "$(__git_flow_list_branches 'feature')"
return return
;; ;;
track) track)
__gitcomp_nl "$(__git_flow_list_branches 'feature')" __gitcomp_nl "$(__git_flow_list_branches 'feature')"
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_release () __git_flow_release ()
{ {
local subcommands="list start finish track publish help delete" local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
finish) finish)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
--sign --sign
--signingkey --signingkey
--message --message
--nomessagefile --messagefile= --nomessagefile --messagefile=
--nopush --push --nopush --push
--nokeep --keep --nokeep --keep
--keepremote --keepremote
--keeplocal --keeplocal
--noforce_delete --force_delete --noforce_delete --force_delete
--notag --tag --notag --tag
--nonobackmerge --nobackmerge --nonobackmerge --nobackmerge
--nosquash --squash --nosquash --squash
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'release')" __gitcomp_nl "$(__git_flow_list_local_branches 'release')"
return return
;; ;;
rebase) rebase)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nointeractive --interactive --nointeractive --interactive
--nopreserve-merges --preserve-merges --nopreserve-merges --preserve-merges
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'release')" __gitcomp_nl "$(__git_flow_list_local_branches 'release')"
return return
;; ;;
delete) delete)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--noforce --force --noforce --force
--noremote --remote --noremote --remote
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'release')" __gitcomp_nl "$(__git_flow_list_local_branches 'release')"
return return
;; ;;
publish) publish)
__gitcomp_nl "$(__git_flow_list_branches 'release')" __gitcomp_nl "$(__git_flow_list_branches 'release')"
return return
;; ;;
track) track)
__gitcomp_nl "$(__git_flow_list_branches 'release')" __gitcomp_nl "$(__git_flow_list_branches 'release')"
return return
;; ;;
start) start)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
" "
return return
;; ;;
esac esac
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_hotfix () __git_flow_hotfix ()
{ {
local subcommands="list start finish track publish help delete" local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
finish) finish)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
--sign --sign
--signingkey --signingkey
--message --message
--nomessagefile --messagefile= --nomessagefile --messagefile=
--nopush --push --nopush --push
--nokeep --keep --nokeep --keep
--keepremote --keepremote
--keeplocal --keeplocal
--noforce_delete --force_delete --noforce_delete --force_delete
--notag --tag --notag --tag
--nonobackmerge --nobackmerge --nonobackmerge --nobackmerge
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
return return
;; ;;
rebase) rebase)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nointeractive --interactive --nointeractive --interactive
--nopreserve-merges --preserve-merges --nopreserve-merges --preserve-merges
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
return return
;; ;;
delete) delete)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--noforce --force --noforce --force
--noremote --remote --noremote --remote
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
return return
;; ;;
publish) publish)
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')" __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
return return
;; ;;
track) track)
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')" __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
return return
;; ;;
start) start)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
" "
return return
;; ;;
esac esac
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_support () __git_flow_support ()
{ {
local subcommands="list start help" local subcommands="list start help"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
start) start)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nofetch --fetch --nofetch --fetch
" "
return return
;; ;;
esac esac
return return
;; ;;
rebase) rebase)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--nointeractive --interactive --nointeractive --interactive
--nopreserve-merges --preserve-merges --nopreserve-merges --preserve-merges
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches 'support')" __gitcomp_nl "$(__git_flow_list_local_branches 'support')"
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_config () __git_flow_config ()
{ {
local subcommands="list set base" local subcommands="list set base"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
return return
fi fi
case "$subcommand" in case "$subcommand" in
set) set)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
$__git_flow_config_file_options $__git_flow_config_file_options
" "
return return
;; ;;
esac esac
__gitcomp " __gitcomp "
master develop master develop
feature hotfix release support feature hotfix release support
versiontagprefix versiontagprefix
" "
return return
;; ;;
base) base)
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
set get set get
" "
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_flow_list_local_branches)" __gitcomp_nl "$(__git_flow_list_local_branches)"
return return
;; ;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
esac esac
} }
__git_flow_prefix () __git_flow_prefix ()
{ {
case "$1" in case "$1" in
feature|release|hotfix|support) feature|release|hotfix|support)
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/" _omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
return return
;; ;;
esac esac
} }
__git_flow_list_local_branches () __git_flow_list_local_branches ()
{ {
if [ -n "$1" ]; then if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \ _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref#$prefix}" ref="${ref#$prefix}"
echo "$ref" echo "$ref"
done | sort done | sort
else else
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort _omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
fi fi
} }
__git_flow_list_remote_branches () __git_flow_list_remote_branches ()
{ {
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")" 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 | \ _omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
echo "$ref" echo "$ref"
done | sort done | sort
} }
__git_flow_list_branches () __git_flow_list_branches ()
{ {
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
if [ -n "$1" ]; then if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \ _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
echo "$ref" echo "$ref"
done | sort done | sort
else else
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort _omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
fi fi
} }
# alias __git_find_on_cmdline for backwards compatibility # alias __git_find_on_cmdline for backwards compatibility
if [ -z "`type -t __git_find_on_cmdline`" ]; then 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 fi

View File

@ -14,7 +14,7 @@ function _go_clear_cache {
unset _go_imports unset _go_imports
} }
function _go_importpath_cache { function _go_importpath_cache {
if [ -z "$_go_imports" ]; then if [ -z "$_go_imports" ]; then
_go_imports=$(go list all 2>/dev/null) _go_imports=$(go list all 2>/dev/null)
export _go_imports export _go_imports
fi fi
@ -53,226 +53,226 @@ _go()
fi fi
case "$cmd" in case "$cmd" in
'build') 'build')
case "$prev" in case "$prev" in
'-o') '-o')
_filedir _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
;; ;;
'clean') '-p')
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 if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "$cmds $other" -- "$cur")) COMPREPLY=($(compgen -W "-a -n -o -p -v -x" -- "$cur"))
else 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 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 esac
} }

View File

@ -5,12 +5,12 @@ function __gradle {
local cache_dir="$HOME/.gradle/completion_cache" local cache_dir="$HOME/.gradle/completion_cache"
case $OSTYPE in case $OSTYPE in
darwin*) 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 md5 -q | md5 -q"
;; ;;
*) *)
local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1" local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1"
;; ;;
esac esac
local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'"

View File

@ -40,17 +40,17 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-s) -s)
unset s unset s
;; ;;
*) *)
for sh in $shells; do for sh in $shells; do
if [ "$sh" = "$i" ]; then if [ "$sh" = "$i" ]; then
unset shells unset shells
break break
fi fi
done done
;; ;;
esac esac
((c++)) ((c++))
done done
@ -67,16 +67,16 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-u) -u)
unset u unset u
;; ;;
*) *)
if [ -z "$repo" ]; then if [ -z "$repo" ]; then
repo=$i repo=$i
else else
subpage=$i subpage=$i
fi fi
;; ;;
esac esac
((c++)) ((c++))
done done
@ -84,14 +84,14 @@ EOF
__gitcomp "$u -- $(__hub_github_repos '\p')" __gitcomp "$u -- $(__hub_github_repos '\p')"
elif [ -z "$subpage" ]; then elif [ -z "$subpage" ]; then
case "$cur" in case "$cur" in
*/*) */*)
local pfx="${cur%/*}" cur_="${cur#*/}" local pfx="${cur%/*}" cur_="${cur#*/}"
local subpages_var="subpages_$pfx" local subpages_var="subpages_$pfx"
__gitcomp "${!subpages_var}" "$pfx/" "$cur_" __gitcomp "${!subpages_var}" "$pfx/" "$cur_"
;; ;;
*) *)
__gitcomp "$u ${subpages_}" __gitcomp "$u ${subpages_}"
;; ;;
esac esac
else else
__gitcomp "$u" __gitcomp "$u"
@ -104,26 +104,26 @@ EOF
while [ $c -gt 1 ]; do while [ $c -gt 1 ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-u) -u)
unset u unset u
;; ;;
*) *)
if [ -z "$rev" ]; then if [ -z "$rev" ]; then
# Even though the logic below is able to complete both user/repo # Even though the logic below is able to complete both user/repo
# and revision in the right place, when there is only one argument # and revision in the right place, when there is only one argument
# (other than -u) in the command, that argument will be taken as # (other than -u) in the command, that argument will be taken as
# revision. For example: # revision. For example:
# $ hub compare -u upstream # $ hub compare -u upstream
# > https://github.com/USER/REPO/compare/upstream # > https://github.com/USER/REPO/compare/upstream
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
arg_repo=$i
else
rev=$i
fi
elif [ -z "$arg_repo" ]; then
arg_repo=$i arg_repo=$i
else
rev=$i
fi fi
;; elif [ -z "$arg_repo" ]; then
arg_repo=$i
fi
;;
esac esac
((c--)) ((c--))
done done
@ -165,20 +165,20 @@ EOF
local pfx cur_="$cur" local pfx cur_="$cur"
case "$cur_" in case "$cur_" in
*..*) *..*)
pfx="${cur_%%..*}..." pfx="${cur_%%..*}..."
cur_="${cur_##*..}" cur_="${cur_##*..}"
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
;; ;;
*) *)
if [ -z "${arg_repo}${rev}" ]; then if [ -z "${arg_repo}${rev}" ]; then
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
elif [ -z "$rev" ]; then elif [ -z "$rev" ]; then
__gitcomp "$u $(__hub_revlist $remote)" __gitcomp "$u $(__hub_revlist $remote)"
else else
__gitcomp "$u" __gitcomp "$u"
fi fi
;; ;;
esac esac
} }
@ -188,16 +188,16 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-d|-h) -d|-h)
((c++)) ((c++))
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
-p) -p)
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
*) *)
name=$i name=$i
;; ;;
esac esac
((c++)) ((c++))
done done
@ -205,12 +205,12 @@ EOF
repo=$(basename "$PWD") repo=$(basename "$PWD")
fi fi
case "$prev" in case "$prev" in
-d|-h) -d|-h)
COMPREPLY=() COMPREPLY=()
;; ;;
-p|*) -p|*)
__gitcomp "$repo $flags" __gitcomp "$repo $flags"
;; ;;
esac esac
} }
@ -220,9 +220,9 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
--no-remote) --no-remote)
unset remote unset remote
;; ;;
esac esac
((c++)) ((c++))
done done
@ -237,33 +237,33 @@ EOF
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-m|-F|-i|-b|-h|-a|-M|-l) -m|-F|-i|-b|-h|-a|-M|-l)
((c++)) ((c++))
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
-f) -f)
flags=${flags/$i/} flags=${flags/$i/}
;; ;;
esac esac
((c++)) ((c++))
done done
case "$prev" in case "$prev" in
-i) -i)
COMPREPLY=() COMPREPLY=()
;; ;;
-b|-h|-a|-M|-l) -b|-h|-a|-M|-l)
# (Doesn't seem to need this...) # (Doesn't seem to need this...)
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved # Uncomment the following line when 'owner/repo:[TAB]' misbehaved
#_get_comp_words_by_ref -n : cur #_get_comp_words_by_ref -n : cur
__gitcomp_nl "$(__hub_heads)" __gitcomp_nl "$(__hub_heads)"
# __ltrim_colon_completions "$cur" # __ltrim_colon_completions "$cur"
;; ;;
-F) -F)
COMPREPLY=( "$cur"* ) COMPREPLY=( "$cur"* )
;; ;;
-f|*) -f|*)
__gitcomp "$flags" __gitcomp "$flags"
;; ;;
esac esac
} }

View File

@ -6,258 +6,258 @@
function_exists() function_exists()
{ {
_omb_util_function_exists "$1" _omb_util_function_exists "$1"
return "$?" return "$?"
} }
function_exists _get_comp_words_by_ref || function_exists _get_comp_words_by_ref ||
_get_comp_words_by_ref () _get_comp_words_by_ref ()
{ {
local exclude cur_ words_ cword_; local exclude cur_ words_ cword_;
if [ "$1" = "-n" ]; then if [ "$1" = "-n" ]; then
exclude=$2; exclude=$2;
shift 2; shift 2;
fi; fi;
__git_reassemble_comp_words_by_ref "$exclude"; __git_reassemble_comp_words_by_ref "$exclude";
cur_=${words_[cword_]}; cur_=${words_[cword_]};
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
cur) cur)
cur=$cur_ cur=$cur_
;; ;;
prev) prev)
prev=${words_[$cword_-1]} prev=${words_[$cword_-1]}
;; ;;
words) words)
words=("${words_[@]}") words=("${words_[@]}")
;; ;;
cword) cword)
cword=$cword_ cword=$cword_
;; ;;
esac; esac;
shift; shift;
done done
} }
function_exists __ltrim_colon_completions || function_exists __ltrim_colon_completions ||
__ltrim_colon_completions() __ltrim_colon_completions()
{ {
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
# Remove colon-word prefix from COMPREPLY items # Remove colon-word prefix from COMPREPLY items
local colon_word=${1%${1##*:}} local colon_word=${1%${1##*:}}
local i=${#COMPREPLY[*]} local i=${#COMPREPLY[*]}
while [[ $((--i)) -ge 0 ]]; do while [[ $((--i)) -ge 0 ]]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
done done
fi fi
} }
function_exists __find_mvn_projects || function_exists __find_mvn_projects ||
__find_mvn_projects() __find_mvn_projects()
{ {
find . -name 'pom.xml' -not -path '*/target/*' -prune | while read LINE ; do find . -name 'pom.xml' -not -path '*/target/*' -prune | while read LINE ; do
local withoutPom=${LINE%/pom.xml} local withoutPom=${LINE%/pom.xml}
local module=${withoutPom#./} local module=${withoutPom#./}
if [[ -z ${module} ]]; then if [[ -z ${module} ]]; then
echo "." echo "."
else else
echo ${module} echo ${module}
fi fi
done done
} }
function_exists _realpath || function_exists _realpath ||
_realpath () _realpath ()
{ {
if [[ -f "$1" ]] if [[ -f "$1" ]]
then
# file *must* exist
if cd "$(echo "${1%/*}")" &>/dev/null
then then
# file *must* exist # file *may* not be local
if cd "$(echo "${1%/*}")" &>/dev/null # exception is ./file.ext
then # try 'cd .; cd -;' *works!*
# file *may* not be local local tmppwd="$PWD"
# exception is ./file.ext cd - &>/dev/null
# try 'cd .; cd -;' *works!*
local tmppwd="$PWD"
cd - &>/dev/null
else
# file *must* be local
local tmppwd="$PWD"
fi
else else
# file *cannot* exist # file *must* be local
return 1 # failure local tmppwd="$PWD"
fi fi
else
# file *cannot* exist
return 1 # failure
fi
# reassemble realpath # reassemble realpath
echo "$tmppwd"/"${1##*/}" echo "$tmppwd"/"${1##*/}"
return 1 #success return 1 #success
} }
function_exists __pom_hierarchy || function_exists __pom_hierarchy ||
__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") POM_HIERARCHY+=("$pom")
while [ -n "$pom" ] && grep -q "<parent>" "$pom"; do done
## 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
} }
_mvn() _mvn()
{ {
local cur prev local cur prev
COMPREPLY=() COMPREPLY=()
POM_HIERARCHY=() POM_HIERARCHY=()
__pom_hierarchy __pom_hierarchy
_get_comp_words_by_ref -n : cur prev _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 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 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_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_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_site_lifecycle="pre-site|site|post-site|site-deploy"
local common_lifecycle_phases="${common_clean_lifecycle}|${common_default_lifecycle}|${common_site_lifecycle}" 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_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_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_ant="ant:ant|ant:clean"
local plugin_goals_antrun="antrun:run" local plugin_goals_antrun="antrun:run"
local plugin_goals_archetype="archetype:generate|archetype:create-from-project|archetype:crawl" local plugin_goals_archetype="archetype:generate|archetype:create-from-project|archetype:crawl"
local plugin_goals_assembly="assembly:single|assembly:assembly" 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_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_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_cargo="cargo:start|cargo:run|cargo:stop|cargo:deploy|cargo:undeploy|cargo:help"
local plugin_goals_checkstyle="checkstyle:checkstyle|checkstyle:check" local plugin_goals_checkstyle="checkstyle:checkstyle|checkstyle:check"
local plugin_goals_cobertura="cobertura:cobertura" local plugin_goals_cobertura="cobertura:cobertura"
local plugin_goals_findbugs="findbugs:findbugs|findbugs:gui|findbugs:help" 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_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_deploy="deploy:deploy-file"
local plugin_goals_ear="ear:ear|ear:generate-application-xml" local plugin_goals_ear="ear:ear|ear:generate-application-xml"
local plugin_goals_eclipse="eclipse:clean|eclipse:eclipse" local plugin_goals_eclipse="eclipse:clean|eclipse:eclipse"
local plugin_goals_ejb="ejb:ejb" local plugin_goals_ejb="ejb:ejb"
local plugin_goals_enforcer="enforcer:enforce|enforcer:display-info" local plugin_goals_enforcer="enforcer:enforce|enforcer:display-info"
local plugin_goals_exec="exec:exec|exec:java" local plugin_goals_exec="exec:exec|exec:java"
local plugin_goals_failsafe="failsafe:integration-test|failsafe:verify" 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_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_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_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_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_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_hibernate3="hibernate3:hbm2ddl|hibernate3:help"
local plugin_goals_idea="idea:clean|idea:idea" local plugin_goals_idea="idea:clean|idea:idea"
local plugin_goals_install="install:install-file" 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_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_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="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_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"
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 #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_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_jxr="jxr:jxr"
local plugin_goals_license="license:format|license:check" 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_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" 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 #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_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_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_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_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_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_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_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_site="site:site|site:deploy|site:run|site:stage|site:stage-deploy"
local plugin_goals_sonar="sonar:sonar|sonar:help" local plugin_goals_sonar="sonar:sonar|sonar:help"
local plugin_goals_source="source:aggregate|source:jar|source:jar-no-fork" local plugin_goals_source="source:aggregate|source:jar|source:jar-no-fork"
local plugin_goals_surefire="surefire:test" 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_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_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_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_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_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_vertx="vertx:init|vertx:runMod|vertx:pullInDeps|vertx:fatJar"
local plugin_goals_war="war:war|war:exploded|war:inplace|war:manifest" 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_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_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_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 ## 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 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}|" local profiles="${profile_settings}|"
for item in ${POM_HIERARCHY[*]} for item in ${POM_HIERARCHY[*]}
do 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 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}" local profiles="${profiles}|${profile_pom}"
done done
local IFS=$'|\n' local IFS=$'|\n'
if [[ ${cur} == -D* ]] ; then if [[ ${cur} == -D* ]] ; then
COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) ) 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
elif [[ ${prev} == -P ]] ; then
if [[ ${cur} == *,* ]] ; then
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) )
else else
if echo "${common_lifecycle_phases}" | tr '|' '\n' | grep -q -e "^${cur}" ; then COMPREPLY=( $(compgen -S ',' -W "${profiles}" -- ${cur}) )
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 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 complete -o default -F _mvn -o nospace mvn

View File

@ -14,113 +14,112 @@
function _salt_get_grains { function _salt_get_grains {
if [ "$1" = 'local' ] ; then if [ "$1" = 'local' ] ; then
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
else else
salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
fi fi
} }
function _salt_get_grain_values { function _salt_get_grain_values {
if [ "$1" = 'local' ] ; then if [ "$1" = 'local' ] ; then
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
else else
salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
fi fi
} }
function _salt { function _salt {
local cur prev opts pprev ppprev local cur prev opts pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ ${COMP_CWORD} -gt 2 ]; then if [ ${COMP_CWORD} -gt 2 ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}" pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi fi
if [ ${COMP_CWORD} -gt 3 ]; then if [ ${COMP_CWORD} -gt 3 ]; then
ppprev="${COMP_WORDS[COMP_CWORD-3]}" ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi fi
opts="-h --help -d --doc --documentation --version --versions-report -c \ opts="-h --help -d --doc --documentation --version --versions-report -c \
--config-dir= -v --verbose -t --timeout= -s --static -b --batch= \ --config-dir= -v --verbose -t --timeout= -s --static -b --batch= \
--batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \ --batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \
--nodegroup -R --range -C --compound -I --pillar \ --nodegroup -R --range -C --compound -I --pillar \
--return= -a --auth= --eauth= --extended-auth= -T --make-token -S \ --return= -a --auth= --eauth= --extended-auth= -T --make-token -S \
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \ --ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= " --out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
if [[ "${cur}" == -* ]] ; then if [[ "${cur}" == -* ]] ; then
COMPREPLY=($(compgen -W '$opts' -- "$cur")) COMPREPLY=($(compgen -W '$opts' -- "$cur"))
return 0 return 0
fi fi
# 2 special cases for filling up grain values # 2 special cases for filling up grain values
case "${pprev}" in case "${pprev}" in
-G|--grain|--grain-pcre) -G|--grain|--grain-pcre)
if [ "${cur}" = ":" ]; then if [ "${cur}" = ":" ]; then
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$prev")')) COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$prev")'))
return 0 return 0
fi fi
;; ;;
esac esac
case "${ppprev}" in case "${ppprev}" in
-G|--grain|--grain-pcre) -G|--grain|--grain-pcre)
if [ "${prev}" = ":" ]; then if [ "${prev}" = ":" ]; then
COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$pprev")' -- "$cur")) COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$pprev")' -- "$cur"))
return 0 return 0
fi fi
;; ;;
esac esac
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
cur="" cur=""
fi fi
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
prev="${pprev}" prev="${pprev}"
fi fi
case "${prev}" in case "${prev}" in
-c|--config)
-c|--config) COMPREPLY=($(compgen -f -- "$cur"))
COMPREPLY=($(compgen -f -- "$cur")) return 0
return 0 ;;
;; salt)
salt) COMPREPLY=($(compgen -W "\'*\' \$opts \$(salt-key --no-color -l acc)" -- "$cur"))
COMPREPLY=($(compgen -W "\'*\' \$opts \$(salt-key --no-color -l acc)" -- "$cur")) return 0
return 0 ;;
;; -E|--pcre)
-E|--pcre) COMPREPLY=($(compgen -W '$(salt-key --no-color -l acc)' -- "$cur"))
COMPREPLY=($(compgen -W '$(salt-key --no-color -l acc)' -- "$cur")) return 0
return 0 ;;
;; -G|--grain|--grain-pcre)
-G|--grain|--grain-pcre) COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur")) return 0
return 0 ;;
;; -C|--compound)
-C|--compound) COMPREPLY=() # TODO: finish this one? how?
COMPREPLY=() # TODO: finish this one? how? return 0
return 0 ;;
;; -t|--timeout)
-t|--timeout) COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- "$cur"))
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- "$cur")) return 0
return 0 ;;
;; -b|--batch|--batch-size)
-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"))
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
return 0 ;;
;; -N|--nodegroup)
-N|--nodegroup) local MASTER_CONFIG='/etc/salt/master'
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")
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")) 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 return 0
} }
@ -129,202 +128,202 @@ complete -F _salt salt
function _saltkey { function _saltkey {
local cur prev opts prev pprev local cur prev opts prev pprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-c --config-dir= -h --help --version --versions-report -q --quiet \ opts="-c --config-dir= -h --help --version --versions-report -q --quiet \
-y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \ -y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \
-l --list= -L --list-all -a --accept= -A --accept-all \ -l --list= -L --list-all -a --accept= -A --accept-all \
-r --reject= -R --reject-all -p --print= -P --print-all \ -r --reject= -R --reject-all -p --print= -P --print-all \
-d --delete= -D --delete-all -f --finger= -F --finger-all \ -d --delete= -D --delete-all -f --finger= -F --finger-all \
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
--out=highstate --out=key --out=txt --no-color --out-indent= " --out=highstate --out=key --out=txt --no-color --out-indent= "
if [ ${COMP_CWORD} -gt 2 ]; then if [ ${COMP_CWORD} -gt 2 ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}" pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi fi
if [ ${COMP_CWORD} -gt 3 ]; then if [ ${COMP_CWORD} -gt 3 ]; then
ppprev="${COMP_WORDS[COMP_CWORD-3]}" ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi fi
if [[ "${cur}" == -* ]] ; then 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")) COMPREPLY=($(compgen -W '$opts' -- "$cur"))
return 0 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 complete -F _saltkey salt-key
function _saltcall { function _saltcall {
local cur prev opts pprev ppprev local cur prev opts pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-h --help -d --doc --documentation --version --versions-report \ opts="-h --help -d --doc --documentation --version --versions-report \
-m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \ -m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
--out=highstate --out=key --out=txt --no-color --out-indent= " --out=highstate --out=key --out=txt --no-color --out-indent= "
if [ ${COMP_CWORD} -gt 2 ]; then if [ ${COMP_CWORD} -gt 2 ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}" pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi fi
if [ ${COMP_CWORD} -gt 3 ]; then if [ ${COMP_CWORD} -gt 3 ]; then
ppprev="${COMP_WORDS[COMP_CWORD-3]}" ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi fi
if [[ "${cur}" == -* ]] ; then if [[ "${cur}" == -* ]] ; then
COMPREPLY=($(compgen -W '$opts' -- "$cur")) 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 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 complete -F _saltcall salt-call
function _saltcp { function _saltcp {
local cur prev opts target prefpart postpart helper filt pprev ppprev local cur prev opts target prefpart postpart helper filt pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-t --timeout= -s --static -b --batch= --batch-size= \ opts="-t --timeout= -s --static -b --batch= --batch-size= \
-h --help --version --versions-report -c --config-dir= \ -h --help --version --versions-report -c --config-dir= \
-E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \ -E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \
-R --range -C --compound -I --pillar \ -R --range -C --compound -I --pillar \
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
--out=highstate --out=key --out=txt --no-color --out-indent= " --out=highstate --out=key --out=txt --no-color --out-indent= "
if [[ "${cur}" == -* ]] ; then if [[ "${cur}" == -* ]] ; then
COMPREPLY=($(compgen -W '$opts' -- "$cur")) COMPREPLY=($(compgen -W '$opts' -- "$cur"))
return 0 return 0
fi fi
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
cur="" cur=""
fi fi
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
prev=${pprev} prev=${pprev}
fi fi
case ${prev} in case ${prev} in
salt-cp) salt-cp)
COMPREPLY=($(compgen -W '$opts $(salt-key -l acc --no-color)' -- "$cur")) COMPREPLY=($(compgen -W '$opts $(salt-key -l acc --no-color)' -- "$cur"))
return 0 return 0
;; ;;
-t|--timeout) -t|--timeout)
# those numbers are just a hint # 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")) COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- "$cur"))
return 0 return 0
;; ;;
-E|--pcre) -E|--pcre)
COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur")) COMPREPLY=($(compgen -W '$(salt-key -l acc --no-color)' -- "$cur"))
return 0 return 0
;; ;;
-L|--list) -L|--list)
# IMPROVEMENTS ARE WELCOME # IMPROVEMENTS ARE WELCOME
prefpart="${cur%,*}," prefpart="${cur%,*},"
postpart=${cur##*,} postpart=${cur##*,}
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$" filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/")) helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
COMPREPLY=($(compgen -W '"${helper[@]}"' -- "$cur")) COMPREPLY=($(compgen -W '"${helper[@]}"' -- "$cur"))
return 0 return 0
;; ;;
-G|--grain|--grain-pcre) -G|--grain|--grain-pcre)
COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur")) COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur"))
return 0 return 0
;; ;;
# FIXME # FIXME
-R|--range) -R|--range)
# FIXME ?? # FIXME ??
return 0 return 0
;; ;;
-C|--compound) -C|--compound)
# FIXME ?? # FIXME ??
return 0 return 0
;; ;;
-c|--config) -c|--config)
COMPREPLY=($(compgen -f -- "$cur")) COMPREPLY=($(compgen -f -- "$cur"))
return 0 return 0
;; ;;
esac esac
# default is using opts: # default is using opts:
COMPREPLY=($(compgen -W '$opts' -- "$cur")) COMPREPLY=($(compgen -W '$opts' -- "$cur"))
} }
complete -F _saltcp salt-cp complete -F _saltcp salt-cp

View File

@ -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") ) COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- "$cur") )
elif ((COMP_CWORD == 2)); then elif ((COMP_CWORD == 2)); then
case ${COMP_WORDS[COMP_CWORD-1]} in case ${COMP_WORDS[COMP_CWORD-1]} in
"install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" ) "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" )
local candidates local candidates
candidates=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ') candidates=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
COMPREPLY=( $(compgen -W "$candidates" -- "$cur") ) COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
;; ;;
"offline" ) "offline" )
COMPREPLY=( $(compgen -W "enable disable" -- "$cur") ) COMPREPLY=( $(compgen -W "enable disable" -- "$cur") )
;; ;;
"selfupdate" ) "selfupdate" )
COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- "$cur") ) COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- "$cur") )
;; ;;
"flush" ) "flush" )
COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- "$cur") ) COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- "$cur") )
;; ;;
*) *)
;; ;;
esac esac
elif ((COMP_CWORD == 3)); then elif ((COMP_CWORD == 3)); then
case ${COMP_WORDS[COMP_CWORD-2]} in case ${COMP_WORDS[COMP_CWORD-2]} in
"install" | "uninstall" | "rm" | "use" | "default" ) "install" | "uninstall" | "rm" | "use" | "default" )
local candidate_versions local candidate_versions
_omb_completion_sdkman__candidate_versions "${COMP_WORDS[COMP_CWORD-1]}" _omb_completion_sdkman__candidate_versions "${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=( $(compgen -W "$candidate_versions" -- "$cur") ) COMPREPLY=( $(compgen -W "$candidate_versions" -- "$cur") )
;; ;;
*) *)
;; ;;
esac esac
fi fi

View File

@ -7,180 +7,179 @@
_tmux_expand () _tmux_expand ()
{ {
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\'; [ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
if [[ "$cur" == \~*/* ]]; then if [[ "$cur" == \~*/* ]]; then
eval cur=$cur; eval cur=$cur;
else else
if [[ "$cur" == \~* ]]; then if [[ "$cur" == \~* ]]; then
cur=${cur#\~}; cur=${cur#\~};
COMPREPLY=($( compgen -P '~' -u $cur )); COMPREPLY=($( compgen -P '~' -u $cur ));
return ${#COMPREPLY[@]}; return ${#COMPREPLY[@]};
fi; fi;
fi fi
} }
_tmux_filedir () _tmux_filedir ()
{ {
local IFS=' local IFS='
'; ';
_tmux_expand || return 0; _tmux_expand || return 0;
if [ "$1" = -d ]; then if [ "$1" = -d ]; then
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur )); COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
return 0; return 0;
fi; fi;
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" )) COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
} }
function _tmux_complete_client() { function _tmux_complete_client() {
local IFS=$'\n' local IFS=$'\n'
local cur="${1}" local cur="${1}"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
} }
function _tmux_complete_session() { function _tmux_complete_session() {
local IFS=$'\n' local IFS=$'\n'
local cur="${1}" local cur="${1}"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
} }
function _tmux_complete_window() { function _tmux_complete_window() {
local IFS=$'\n' local IFS=$'\n'
local cur="${1}" local cur="${1}"
local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)" local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
local sessions local sessions
sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')" sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')"
if [[ -n "${session_name}" ]]; then if [[ -n "${session_name}" ]]; then
sessions="${sessions} sessions="${sessions}
$(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')" $(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')"
fi fi
cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')" cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')" sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
} }
function _tmux { function _tmux {
local cur prev local cur prev
local i cmd cmd_index option option_index local i cmd cmd_index option option_index
local opts="" local opts=""
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ ${prev} == -f ]; then if [ ${prev} == -f ]; then
_tmux_filedir _tmux_filedir
else else
# Search for the command # Search for the command
local skip_next=0 local skip_next=0
for ((i=1; $i<=$COMP_CWORD; i++)); do for ((i=1; $i<=$COMP_CWORD; i++)); do
if [[ ${skip_next} -eq 1 ]]; then if [[ ${skip_next} -eq 1 ]]; then
#echo "Skipping" #echo "Skipping"
skip_next=0; skip_next=0;
elif [[ ${COMP_WORDS[i]} != -* ]]; then elif [[ ${COMP_WORDS[i]} != -* ]]; then
cmd="${COMP_WORDS[i]}" cmd="${COMP_WORDS[i]}"
cmd_index=${i} cmd_index=${i}
break break
elif [[ ${COMP_WORDS[i]} == -f ]]; then elif [[ ${COMP_WORDS[i]} == -f ]]; then
skip_next=1 skip_next=1
fi fi
done done
# Search for the last option command # Search for the last option command
skip_next=0 skip_next=0
for ((i=1; $i<=$COMP_CWORD; i++)); do for ((i=1; $i<=$COMP_CWORD; i++)); do
if [[ ${skip_next} -eq 1 ]]; then if [[ ${skip_next} -eq 1 ]]; then
#echo "Skipping" #echo "Skipping"
skip_next=0; skip_next=0;
elif [[ ${COMP_WORDS[i]} == -* ]]; then elif [[ ${COMP_WORDS[i]} == -* ]]; then
option="${COMP_WORDS[i]}" option="${COMP_WORDS[i]}"
option_index=${i} option_index=${i}
if [[ ${COMP_WORDS[i]} == -- ]]; then if [[ ${COMP_WORDS[i]} == -- ]]; then
break; break;
fi
elif [[ ${COMP_WORDS[i]} == -f ]]; then
skip_next=1
fi fi
elif [[ ${COMP_WORDS[i]} == -f ]]; then
skip_next=1
fi
done done
if [[ $COMP_CWORD -le $cmd_index ]]; then if [[ $COMP_CWORD -le $cmd_index ]]; then
# The user has not specified a command yet # The user has not specified a command yet
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") )
else else
case ${cmd} in case ${cmd} in
attach-session|attach) attach-session|attach)
case "$prev" in case "$prev" in
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
*) options="-t -d" ;; *) options="-t -d" ;;
esac ;; esac ;;
detach-client|detach) detach-client|detach)
case "$prev" in case "$prev" in
-t) _tmux_complete_client "${cur}" ;; -t) _tmux_complete_client "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
lock-client|lockc) lock-client|lockc)
case "$prev" in case "$prev" in
-t) _tmux_complete_client "${cur}" ;; -t) _tmux_complete_client "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
lock-session|locks) lock-session|locks)
case "$prev" in case "$prev" in
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
*) options="-t -d" ;; *) options="-t -d" ;;
esac ;; esac ;;
new-session|new) new-session|new)
case "$prev" in case "$prev" in
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
-[n|d|s]) options="-d -n -s -t --" ;; -[n|d|s]) options="-d -n -s -t --" ;;
*) *)
if [[ ${COMP_WORDS[option_index]} == -- ]]; then if [[ ${COMP_WORDS[option_index]} == -- ]]; then
_command_offset ${option_index} _command_offset ${option_index}
else else
options="-d -n -s -t --" options="-d -n -s -t --"
fi fi
;; ;;
esac esac
;; ;;
refresh-client|refresh) refresh-client|refresh)
case "$prev" in case "$prev" in
-t) _tmux_complete_client "${cur}" ;; -t) _tmux_complete_client "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
rename-session|rename) rename-session|rename)
case "$prev" in case "$prev" in
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
source-file|source) _tmux_filedir ;; source-file|source) _tmux_filedir ;;
has-session|has|kill-session) has-session|has|kill-session)
case "$prev" in case "$prev" in
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
suspend-client|suspendc) suspend-client|suspendc)
case "$prev" in case "$prev" in
-t) _tmux_complete_client "${cur}" ;; -t) _tmux_complete_client "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
switch-client|switchc) switch-client|switchc)
case "$prev" in case "$prev" in
-c) _tmux_complete_client "${cur}" ;; -c) _tmux_complete_client "${cur}" ;;
-t) _tmux_complete_session "${cur}" ;; -t) _tmux_complete_session "${cur}" ;;
*) options="-l -n -p -c -t" ;; *) options="-l -n -p -c -t" ;;
esac ;; esac ;;
send-keys|send) send-keys|send)
case "$option" in case "$option" in
-t) _tmux_complete_window "${cur}" ;; -t) _tmux_complete_window "${cur}" ;;
*) options="-t" ;; *) options="-t" ;;
esac ;; esac ;;
esac # case ${cmd} esac # case ${cmd}
fi # command specified fi # command specified
fi # not -f fi # not -f
if [[ -n "${options}" ]]; then if [[ -n "${options}" ]]; then
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
fi fi
return 0
return 0
} }
complete -F _tmux tmux complete -F _tmux tmux

View File

@ -24,124 +24,124 @@
function __pwdln { function __pwdln {
pwdmod="${PWD}/" pwdmod="${PWD}/"
itr=0 itr=0
until [[ -z "$pwdmod" ]];do until [[ -z "$pwdmod" ]];do
itr=$(($itr+1)) itr=$(($itr+1))
pwdmod="${pwdmod#*/}" pwdmod="${pwdmod#*/}"
done done
echo -n $(($itr-1)) echo -n $(($itr-1))
} }
function __vagrantinvestigate { function __vagrantinvestigate {
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
echo "${PWD}/.vagrant" echo "${PWD}/.vagrant"
return 0 return 0
else else
pwdmod2="${PWD}" pwdmod2="${PWD}"
for (( i=2; i<=$(__pwdln); i++ ));do for (( i=2; i<=$(__pwdln); i++ ));do
pwdmod2="${pwdmod2%/*}" pwdmod2="${pwdmod2%/*}"
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ];then if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ];then
echo "${pwdmod2}/.vagrant" echo "${pwdmod2}/.vagrant"
return 0 return 0
fi fi
done done
fi fi
return 1 return 1
} }
function _vagrant { function _vagrant {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" 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" 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 ] if [ $COMP_CWORD == 1 ]
then 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})) COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0 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 ] if [ $COMP_CWORD == 3 ]
then then
case "$prev" in action="${COMP_WORDS[COMP_CWORD-2]}"
"init") case "$action" in
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//') "up")
COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) if [ "$prev" == "--no-provision" ]; then
return 0 COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
;; return 0
"up") fi
vagrant_state_file=$(__vagrantinvestigate) || return 1 ;;
if [[ -d $vagrant_state_file ]] "box")
then case "$prev" in
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) "remove"|"repackage")
fi local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
local up_commands="--no-provision" COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur})) return 0
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
;;
esac 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 complete -F _vagrant vagrant

View File

@ -1,85 +1,85 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
function _vboxmanage_realopts { function _vboxmanage_realopts {
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ') echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
echo " " echo " "
} }
function __vboxmanage_startvm { function __vboxmanage_startvm {
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"') RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"') TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
AVAILABLE="" AVAILABLE=""
for VM in $TOTAL; do for VM in $TOTAL; do
MATCH=0; MATCH=0;
for RUN in $RUNNING "x"; do for RUN in $RUNNING "x"; do
if [ "$VM" == "$RUN" ]; then if [ "$VM" == "$RUN" ]; then
MATCH=1 MATCH=1
fi fi
done
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
done done
echo $AVAILABLE (( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
done
echo $AVAILABLE
} }
function __vboxmanage_list { function __vboxmanage_list {
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-) INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
PRUNED="" PRUNED=""
if [ "$1" == "long" ]; then if [ "$1" == "long" ]; then
for WORD in $INPUT; do for WORD in $INPUT; do
[ "$WORD" == "-l" ] && continue; [ "$WORD" == "-l" ] && continue;
[ "$WORD" == "--long" ] && continue; [ "$WORD" == "--long" ] && continue;
PRUNED="$PRUNED $WORD" PRUNED="$PRUNED $WORD"
done done
else else
PRUNED=$INPUT PRUNED=$INPUT
fi fi
echo $PRUNED echo $PRUNED
} }
function __vboxmanage_list_vms { function __vboxmanage_list_vms {
VMS="" VMS=""
if [ "x$1" == "x" ]; then if [ "x$1" == "x" ]; then
SEPARATOR=" " SEPARATOR=" "
else else
SEPARATOR=$1 SEPARATOR=$1
fi fi
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS echo $VMS
} }
function __vboxmanage_list_runningvms { function __vboxmanage_list_runningvms {
VMS="" VMS=""
if [ "$1" == "" ]; then if [ "$1" == "" ]; then
SEPARATOR=" " SEPARATOR=" "
else else
SEPARATOR=$1 SEPARATOR=$1
fi fi
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS
echo $VMS
} }
function __vboxmanage_controlvm { function __vboxmanage_controlvm {
echo "pause resume reset poweroff savestate acpipowerbutton" echo "pause resume reset poweroff savestate acpipowerbutton"
echo "acpisleepbutton keyboardputscancode guestmemoryballoon" echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport" echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
echo "vrdeproperty vrdevideochannelquality setvideomodehint" echo "vrdeproperty vrdevideochannelquality setvideomodehint"
echo "screenshotpng setcredentials teleport plugcpu unplugcpu" echo "screenshotpng setcredentials teleport plugcpu unplugcpu"
echo "cpuexecutioncap" echo "cpuexecutioncap"
# setlinkstate<1-N> # setlinkstate<1-N>
# nic<1-N> null|nat|bridged|intnet|hostonly|generic # nic<1-N> null|nat|bridged|intnet|hostonly|generic
@ -94,129 +94,129 @@ function __vboxmanage_controlvm {
} }
function __vboxmanage_default { function __vboxmanage_default {
realopts=$(_vboxmanage_realopts) realopts=$(_vboxmanage_realopts)
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq) opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
pruned="" pruned=""
# echo "" # echo ""
# echo "DEBUG: cur: $cur, prev: $prev" # echo "DEBUG: cur: $cur, prev: $prev"
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|" # echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
case ${cur} in case ${cur} in
-*) -*)
echo $opts echo $opts
# COMPREPLY=($(compgen -W "${opts}" -- ${cur})) # 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 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 { function _vboxmanage {
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq # vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
local cur p1 p2 p3 p4 opts local cur p1 p2 p3 p4 opts
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
# echo "cur: |$cur|" # echo "cur: |$cur|"
# echo "prev: |$prev|" # echo "prev: |$prev|"
# In case current is complete command # In case current is complete command
case $cur in case $cur in
startvm|list|controlvm) startvm|list|controlvm)
COMPREPLY=($(compgen -W "$cur ")) COMPREPLY=($(compgen -W "$cur "))
return 0 return 0
;; ;;
esac esac
case $prev in case $prev in
-v|--version) -v|--version)
return 0 return 0
;; ;;
-l|--long) -l|--long)
opts=$(__vboxmanage_list "long") opts=$(__vboxmanage_list "long")
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
startvm|list) startvm|list)
opts=$(__vboxmanage_$prev) opts=$(__vboxmanage_$prev)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
--type) --type)
COMPREPLY=($(compgen -W "gui headless" -- ${cur})) COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
return 0 return 0
;; ;;
gui|headless) gui|headless)
# Done. no more completion possible # Done. no more completion possible
return 0 return 0
;; ;;
vboxmanage|-q|--nologo) vboxmanage|-q|--nologo)
# echo "Got vboxmanage" # echo "Got vboxmanage"
opts=$(__vboxmanage_default) opts=$(__vboxmanage_default)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
controlvm) controlvm)
opts=$(__vboxmanage_list_vms) opts=$(__vboxmanage_list_vms)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
esac esac
for VM in $(__vboxmanage_list_vms); do for VM in $(__vboxmanage_list_vms); do
if [ "$VM" == "$prev" ]; then if [ "$VM" == "$prev" ]; then
pprev=${COMP_WORDS[COMP_CWORD-2]} pprev=${COMP_WORDS[COMP_CWORD-2]}
# echo "previous: $pprev" # echo "previous: $pprev"
case $pprev in case $pprev in
startvm) startvm)
opts="--type" opts="--type"
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
controlvm) controlvm)
opts=$(__vboxmanage_controlvm) opts=$(__vboxmanage_controlvm)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0; return 0;
;; ;;
esac esac
fi fi
done done
# echo "Got to end withoug completion" # echo "Got to end withoug completion"
} }
complete -F _vboxmanage vboxmanage complete -F _vboxmanage vboxmanage