Skip to content

Instantly share code, notes, and snippets.

@toddself
Created August 21, 2014 01:20
Show Gist options
  • Save toddself/d8edaa7aee7e3a47183a to your computer and use it in GitHub Desktop.
Save toddself/d8edaa7aee7e3a47183a to your computer and use it in GitHub Desktop.
function vms(){
if [[ -n $(which vboxmanage) ]]; then
VMNAME=" "
if [[ -d .vagrant ]]; then
for MACHINE in `ls .vagrant/machines`; do
IDFILE=".vagrant/machines/$MACHINE/virtualbox/id";
if [ -f $IDFILE ]; then
ID=$(cat $IDFILE);
VMNAME=$(vboxmanage list runningvms| grep $ID | awk -F'["_]' '{print $2}');
fi
done
if [ "$VMNAME" != "" ]; then
if [ "$VMNAME" != " " ]; then
echo -e "$GREEN vm:$VMNAME$OFF"
fi
else
echo -e "$GREEN vm:off$OFF"
fi
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment