Skip to content

Instantly share code, notes, and snippets.

@tuongaz
Last active August 29, 2015 13:57
Show Gist options
  • Save tuongaz/9719301 to your computer and use it in GitHub Desktop.
Save tuongaz/9719301 to your computer and use it in GitHub Desktop.
Quick function to run Vagrant servers
function sv() {
SERVERS_DIR=/Users/tuongaz/servers
if [[ $# == 0 ]]; then
printf "sv server command\n"
printf "List servers:\n"
for dir in $(ls $SERVERS_DIR)
do
if [[ -d "$SERVERS_DIR/$dir" ]]; then
printf "* $dir\n"
fi
done
return 2
fi
server="$SERVERS_DIR/$1"
command=${2:-up}
#Check if the server exists.
if [[ ! -d "$server" ]]; then
echo "Server $1 does not exist."
return 2
fi
cd $server
vagrant $command
}
#Example: sv development ssh : SSH login to the Vagrant development server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment