vbox

vbox lets you manipulate (start, stop, pause, suspend) VirtualBox VMs, and change shared folders.
git clone git://git.alex.balgavy.eu/vbox.git
Log | Files | Refs | README | LICENSE

_vbox (1315B)


      1 #compdef vbox
      2 _vboxmachines() {
      3     VBoxManage list vms | egrep -o '^"[^"]+"' 2>/dev/null | sed -e 's|"||g' | while read machine; do
      4         _wanted 'machine' expl 'machine' compadd $machine
      5     done
      6 }
      7 _vbox() {
      8   local -a arguments
      9   arguments=(
     10     'start:start a VM'
     11     'stop:stop a VM'
     12     'open:open a VM, starting it if necessary'
     13     'pause:pause a VM'
     14     'suspend:suspend a VM'
     15     'resume:resume a paused VM'
     16     'ls:list known VMs'
     17     'info:get information about a VM'
     18     'status:get status of a VM'
     19     'running:list currently running VMs'
     20     'share:share a local folder'
     21     'unshare:unshare a local folder'
     22     'sharetmp:temporarily share a local folder'
     23     'shared:list shared folders for a VM'
     24   )
     25   local context state line expl
     26   local -A opt_args
     27   _arguments '*:: :->subcmds' && return 0
     28 
     29   if (( CURRENT == 1 )); then
     30     _describe -t commands "vbox commands" arguments -V1
     31     return
     32   fi
     33 
     34   case "$words[1]" in
     35     share|sharetmp)
     36       _arguments \
     37         ':hostpath:_files -/' \
     38         :machine:_vboxmachines \
     39         ':name: :'
     40       ;;
     41     unshare)
     42       _arguments \
     43         ':hostpath:_files -/' \
     44         :machine:_vboxmachines
     45       ;;
     46     start|stop|open|status|info|shared|pause|suspend|resume)
     47       _arguments \
     48         :machine:_vboxmachines
     49       ;;
     50   esac
     51   return 1
     52 }