Skip to content

Instantly share code, notes, and snippets.

@euikook
Last active July 26, 2016 08:27
Show Gist options
  • Save euikook/7b0bc0a2ba318c7653469aea387e58bc to your computer and use it in GitHub Desktop.
Save euikook/7b0bc0a2ba318c7653469aea387e58bc to your computer and use it in GitHub Desktop.
Headless start VirtualBox VM
#!/usr/bin/env bash
# ~/bin/start-vm
VBoxManage startvm $1 --type headless
# /etc/bash_completion.d/start-vm
_start_vm()
{
local cur prev command module i
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
VM_LIST=`VBoxManage list vms | awk '{print $1}' | sed 's/\"//g'`
if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $(compgen -W '$VM_LIST' -- $cur) )
fi
}
complete -F _start_vm start-vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment