-
-
Save tuongaz/9719301 to your computer and use it in GitHub Desktop.
Quick function to run Vagrant servers
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 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