8aec32b48bb88e980150a43586e7e02b9156e165

Author
Allan Caffee <allanc@aweber.com>
Committer
Allan Caffee <allanc@aweber.com>
Date

Message

Add vagrant completion for individual VMs

For multi-VM setups some commands take the name of
a virtual machine.  Read the Vagrantfile and offer
suggestions.

Diff

 1diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant
 2index 483b29c53d57186b01ec55d780f8debce0cb5995..9bed1e3c69d845c00100e21fdb2103a9d66dee4e 100644
 3--- a/plugins/vagrant/_vagrant
 4+++ b/plugins/vagrant/_vagrant
 5@@ -46,6 +46,11 @@ __box_list ()
 6     _wanted application expl 'command' compadd $(command ls -1 $HOME/.vagrant/boxes 2>/dev/null| sed -e 's/ /\\ /g')
 7 }
 8 
 9+__vm_list ()
10+{
11+    _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *:\([a-zA-Z0-9]\+\)' 2>/dev/null | cut -d: -f2)
12+}
13+
14 __vagrant-box ()
15 {
16     local curcontext="$curcontext" state line
17@@ -99,6 +104,8 @@ case $state in
18       (box)
19           __vagrant-box
20       ;;
21+      (up|provision|package|destroy|reload|ssh|halt|resume|status)
22+	_arguments ':feature:__vm_list'
23     esac
24   ;;
25 esac