contrib/bash: Auto-complete VMs for up command
This commit is contained in:
parent
8b8f2b26a6
commit
0b737b8683
|
@ -70,8 +70,13 @@ _vagrant() {
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
"up")
|
"up")
|
||||||
|
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||||
|
if [[ -d $vagrant_state_file ]]
|
||||||
|
then
|
||||||
|
local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||||
|
fi
|
||||||
local up_commands="--no-provision"
|
local up_commands="--no-provision"
|
||||||
COMPREPLY=($(compgen -W "${up_commands}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
||||||
|
@ -107,8 +112,19 @@ _vagrant() {
|
||||||
if [ $COMP_CWORD == 3 ]
|
if [ $COMP_CWORD == 3 ]
|
||||||
then
|
then
|
||||||
action="${COMP_WORDS[COMP_CWORD-2]}"
|
action="${COMP_WORDS[COMP_CWORD-2]}"
|
||||||
if [ $action == 'box' ]
|
case "$action" in
|
||||||
|
"up")
|
||||||
|
if [ "$prev" == "--no-provision" ]
|
||||||
then
|
then
|
||||||
|
if [[ -d $vagrant_state_file ]]
|
||||||
|
then
|
||||||
|
local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||||
|
fi
|
||||||
|
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"box")
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
"remove"|"repackage")
|
"remove"|"repackage")
|
||||||
local box_list=$(find "${VAGRANT_HOME:-${HOME}/.vagrant.d}/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
local box_list=$(find "${VAGRANT_HOME:-${HOME}/.vagrant.d}/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||||
|
@ -118,7 +134,10 @@ _vagrant() {
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue