Skip to content

Instantly share code, notes, and snippets.

@unlucio

unlucio/vm.sh Secret

Created June 18, 2015 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save unlucio/a39f3cda50439b6de59a to your computer and use it in GitHub Desktop.
Save unlucio/a39f3cda50439b6de59a to your computer and use it in GitHub Desktop.
simple vm management script
#!/bin/sh
if [ -z "$vmFile" ]
then
echo "please set your 'vmFile' environment variable to point to your vm's .vmx file"
exit 1
fi
case "$1" in
start)
vmrun start "$vmFile" nogui
;;
stop)
vmrun stop "$vmFile" nogui
;;
suspend)
vmrun suspend "$vmFile" nogui
;;
pause)
vmrun pause "$vmFile" nogui
;;
unpause)
vmrun unpause "$vmFile" nogui
;;
reset)
vmrun reset "$vmFile" nogui
;;
status)
vmrun list
;;
*)
echo "Usage: possible options are: start | stop | suspend | pause | unpause | reset | status"
exit 1
esac
@unlucio
Copy link
Author

unlucio commented Jun 18, 2015

so I got kind of annoyied by the aliases I did for the vm and I came up witht this.

how to use it:

$ sudo ln -s "/Applications/VMware Fusion.app/Contents/Library/vmrun" /usr/bin/vmrun
$ curl https://gist.githubusercontent.com/unlucio/a39f3cda50439b6de59a/raw/3766e3709aee74b1430c4fb089b6c241e584ff20/vm.sh -o vm
$ chmod a+x vm
$ sudo mv vm /usr/bin

and add a vmFile env var to your .zshrc:

export vmFile="/Users/lucio/Documents/Virtual Machines.localized/Ubuntu 15.04 server64-bit.vmwarevm/Ubuntu 15.04 server64-bit.vmx"

enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment