Skip to content

Instantly share code, notes, and snippets.

@metaodi
Created May 31, 2015 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaodi/6d589bc81e5fd7ea1d2c to your computer and use it in GitHub Desktop.
Save metaodi/6d589bc81e5fd7ea1d2c to your computer and use it in GitHub Desktop.
Status of all local vagrant boxes
#!/bin/bash
root_dir="$HOME"
if [ -n "$1" ] ; then
root_dir=$1
fi
for vdir in `find $root_dir -name .vagrant -type d 2>/dev/null`; do
cd $vdir
cd ..
vtext=`vagrant status 2>/dev/null | awk '{$1=""; print $0}' | sed 's/^ //g' | grep 'virtualbox' | GREP_COLOR="2;32" egrep --color=always "(not created|poweroff)"`
if [ -z "$vtext" ] ; then
vtext=`vagrant status 2>/dev/null | awk '{$1=""; print $0}' | sed 's/^ //g' | grep 'virtualbox' | egrep --color=always "(running)"`
fi
if [ -z "$vtext" ] ; then
vtext=`echo missing | GREP_COLOR="2;36" egrep --color=always "(missing)"`
fi
echo "$vtext: "`pwd`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment