Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

vagrant bash completion script

  • Loading branch information...
commit 87e80431414f2122a8beee5b3249c893753c0a58 1 parent 85d76f9
@baob authored
Showing with 50 additions and 0 deletions.
  1. +50 −0 completion.d/vagrant
View
50 completion.d/vagrant
@@ -0,0 +1,50 @@
+#!/bin/bash
+_vagrant()
+{
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version"
+
+ if [ $COMP_CWORD == 1 ]
+ then
+ COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
+ return 0
+ fi
+
+ if [ $COMP_CWORD == 2 ]
+ then
+ case "$prev" in
+ "box")
+ box_commands="add help list remove repackage"
+ COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
+ return 0
+ ;;
+ "help")
+ COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+ fi
+
+ if [ $COMP_CWORD == 3 ]
+ then
+ action="${COMP_WORDS[COMP_CWORD-2]}"
+ if [ $action == 'box' ]
+ then
+ case "$prev" in
+ "remove"|"repackage")
+ local box_list=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ')
+ COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+ fi
+ fi
+
+}
+complete -F _vagrant vagrant
+
Please sign in to comment.
Something went wrong with that request. Please try again.