Last active
December 18, 2015 11:29
-
-
Save scarolan/5775596 to your computer and use it in GitHub Desktop.
"vlist" and "vssh" commands for working with Vagrant virtual machines. Drop these in your .bashrc. vlist creates a list of all your running VMs.
vssh loops through all your VMs, and attempts to run commands on each of them.
This file contains hidden or 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
# vlist generates a list of running Vagrant VMs | |
vlist () | |
{ | |
vagrant status | awk '/running/{ print $1 }' | |
} | |
# vssh runs your command(s) on all VMs. Enclose in quotes to run multiple commands. | |
vssh () | |
{ | |
[ $# -ne 1 ] && (echo "Usage: vssh command"; return 1) | |
command="$1"; | |
for host in $(vlist); | |
do | |
vagrant ssh $host -c "$command"; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to properly parse multiple commands.