VMware Fusion CLI “vmrun” and bashrc tricks

VMware Fusion is a good application to run Windows or Linux virtual machines on the Mac. I use it to test out some quick cluster or networked applications testing where I do need multiple Linux systems. VMware Fusion may slow down your overall Mac desktop experience as its windowing application is a bit heavy. When you run multiple VM’s together then it is slow. So here below are ~/.bashrc tricks that I do use all the time.

~/.bashrc is a shell script that “the Bash shell” runs whenever it is started. The purpose of a ~/.bashrc file is for you to set up environment variables, functions, aliases, and define your (PS1) prompt, etc for your bash session. Now, let’s talk about the VMware Fusion tricks.

Just place the below functions snippet in your ~/.bashrc if you want to start/stop/list your VM’s from the terminal.

# VMWare easy commands via functions
vmup() {
[ $1 ] && /Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion start ~/Virtual\ Machines.localized/$1.vmwarevm/$1.vmx nogui || echo "Please provide VM name"
}

Here how I use these functions from the terminal. It works just like alias settings.

~ >_ vmlist
All available VMs: c0 c1 c2 c3 d1 hadoop k0 k1 k2 k3 www
All running VMs:

Not just that, this “vmrun” command does a lot more like showing your VMware-created network soft devices, create/delete VM snapshots, and rebooting any VM, etc.

~ >_ vmrun listHostNetworks
Total host networks: 3
INDEX NAME TYPE DHCP SUBNET MASK
0 vmnet0 bridged false empty empty
1 vmnet1 hostOnly true 172.16.108.0 255.255.255.0
8 vmnet8 nat true 192.168.75.0 255.255.255.0

Hope it helps some of you who have a similar use case.

That’s all :-)