Skip to content

Instantly share code, notes, and snippets.

@toddself
Created May 24, 2014 15:19
Show Gist options
  • Save toddself/2562702304c4df313e3d to your computer and use it in GitHub Desktop.
Save toddself/2562702304c4df313e3d to your computer and use it in GitHub Desktop.
function vms(){
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment