Created
August 21, 2014 01:20
-
-
Save toddself/d8edaa7aee7e3a47183a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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