virtualbox/virtualbox.plugin.zsh

25 lines
907 B
Bash
Raw Permalink Normal View History

2017-09-04 12:31:18 +00:00
vb() {
case $1 in
list) vboxmanage list vms | awk '{print $1}' | tr -d '"' | sort;;
start) vboxmanage startvm $2 --type headless;;;
gui) vboxmanage startvm $2 --type separate;;
stop) vboxmanage controlvm $2 acpipowerbutton || vboxmanage controlvm $2 poweroff;;
suspend) vboxmanage controlvm $2 savestate;;
restart) vb stop $2; vb start $2;;
reset) vboxmanage controlvm $2 reset;;
status)
VMS=$2
[[ $# -eq 1 ]] && VMS=$(vb list)
for VM in ${=VMS}; do
echo -n "$VM: "
vboxmanage list runningvms | grep -q $VM && echo "running" || echo "stopped"
done
;;
snapshot) vboxmanage snapshot $2 take ${3:-"$(date +%s)-$2"};;
snaprestore) vboxmanage snapshot $2 restore ${3};;
snaplist) vboxmanage snapshot $2 list | cut -d: -f2-;;
snapdel) vboxmanage snapshot $2 delete $3;;
*) echo "unknown parameter: $1"; return 1;;
esac
}