virtualbox/_vb

41 lines
850 B
Text
Raw Permalink Normal View History

2017-09-04 12:31:18 +00:00
#compdef vb
2018-11-15 19:50:35 +00:00
#autoload
2017-09-04 12:31:18 +00:00
_vb() {
local state
_arguments -C '1: :->actions' '2: :->vms' '3: :->snapshots'
case $state in
(actions)
local actions
actions=("list:List all VMs"
"start:Start VM"
2018-02-26 17:14:00 +00:00
"gui:Connect graphical gui"
2017-09-04 12:31:18 +00:00
"stop:Stop VM"
"suspend:Suspend VM"
"restart:Restart VM"
"reset:Reset VM"
"status:Show status"
"snapshot:Create new snapshot"
"snaprestore:Restore snapshots"
"snaplist:List snapshots"
"snapdel:Delete snapshot")
_describe 'actions' actions
;;
(vms)
2018-06-15 22:10:54 +00:00
compadd -- $(vboxmanage list vms | awk -F\" '{print $2}' | xargs)
2017-09-04 12:31:18 +00:00
;;
(snapshots)
local snapshot_list
[[ $line[1] =~ 'snapdel|snaprestore' ]] || return
snapshot_list=$(vboxmanage snapshot $line[2] list)
[[ $? -ne 0 ]] && return
compadd -- $(awk '{print $2}' <<<$snapshot_list)
;;
esac
}
_vb "$@"