I have several projects using Vagrant, and often forget to `vagrant halt` before switching projects, wasting computer resources.
Is there a way to query which projects currently have Vagrant VMs running, so I can know where I should `cd` and shut them down?
You could either use the ‘vagrant status’ command to list which boxes you currently have up, or use your providers software to manage them. For example, if you use virtualbox, just run the gui (simply the ‘virtualbox’ command in terminal) and you will be able to see which VMs you have up there.
This will turn off every vm you have running, no matter where it’s running from:
VBoxManage list runningvms | awk ‘{print $2;}’ | xargs -I vmid VBoxManage controlvm vmid poweroff
Perhaps usefull for others browsing /r/vagrant, the current Vagrant release supports the command global-status which was included to answer exaxtly these kinds of questions.