The purpose of this shell command is to make the vagrant commands
- slightly easier to use if you're not already in the Vagrant directory
- parallel
(Not gonna lie, 2 was actually the bigger motivator. Can't tell you how many times I typed vagrant down
to have nothing happen.)
The file is structured a little oddly because it's actually part of another, larger command used for deployments and the like. If there are any bugs, let me know, as I probably didn't parse it out very carefully.
- Copy the script somehwere.
- Set an alias in your .bash_profile or .bash_rc or w/e. Be sure to include a period before the path to the file, else
dir
will not work. Example:
alias v=. ~/.scripts/vagrant.sh
I have mine aliased as "v". Thus, if I'm in the folder of a box,
v up
v down
v reup
is the same as
vagrant up
vagrant halt
vagrant reload
is the same as
v boot
v deboot
v reboot
and you can use any of those that you like, mixing and matching. You can also use v halt
and v reload
if you like installing scripts for no reason (or just want to use the aliasing for boxes).
But those are the basics. Let's say you just opened the terminal and want to shutdown the box that's running at /users/you/sites/awesomesite. You can just
v down awesomesite
Want to bring up /users/you/awesomesite2? Just
v up awesomesite2
(Reboot works the same way.)
Oh, and if you want to go the folder where a box is located, just
v dir awesomesite
(I guess you can do that from within the folder without the name, but ... congrats you did nothing?)
status
just gets passed, so v status awesomesite
gets you the information for awesomesite.
All done for the day? Better shut them all down!
v down all
(Note: If you have a box in a folder called "all," you won't be able to shut it down this way. You will shut down all boxes. Sorry not sorry.)
If for some reason you want ALL OF THE BOXES TO LOAD?
v boot all
"All" works for the up
ing and down
ing commands.
You can also v destroy
and v kill
, either inside the folder (no name) or with the box name. You cannot "all" those commands, because I would definitely accidentally destroy all my boxes every other week.
Also v status all
is vagrant global-status.
If you have very generic box or folder titles, it might affect all boxes that match the text you type in. So, y'know, use your brain. For exmaple, v down awesomesite
might take down both sites in the previous examples. Not sure. I'd look at that, but I just name stuff more uniquely, so it's not a problem for me.