Merge pull request #3755 from kura/vagrant-1.6-bash-completion

Merging in latest version from kura/vagrant-bash-completion
This commit is contained in:
Mitchell Hashimoto 2014-05-12 08:28:48 -07:00
commit 0feae47da3
1 changed files with 14 additions and 7 deletions

View File

@ -22,6 +22,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
__pwdln() { __pwdln() {
pwdmod="${PWD}/" pwdmod="${PWD}/"
itr=0 itr=0
@ -52,7 +53,7 @@ __vagrantinvestigate() {
_vagrant() { _vagrant() {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="box connect destroy halt help init list-commands login package plugin provision reload resume rsync rsync-auto share ssh ssh-config status suspend up" commands="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
@ -68,13 +69,19 @@ _vagrant() {
COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
return 0 return 0
;; ;;
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config"|"up") "up")
local up_commands="--no-provision"
COMPREPLY=($(compgen -W "${up_commands}" -- ${cur}))
return 0
;;
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
vagrant_state_file=$(__vagrantinvestigate) || return 1 vagrant_state_file=$(__vagrantinvestigate) || return 1
if [[ -f $vagrant_state_file ]]; then if [[ -f $vagrant_state_file ]]
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ') then
else running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}') else
fi running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
fi
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur})) COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
return 0 return 0
;; ;;