Alex Kotliarskyi wrote a great little script to show OS X desktop notifications when a long-running terminal command finishes (and is not in focus).
Making it work with a Vagrant virtual machine turned out to be straightforward. These instructions assume zsh as shell, bash might work similarly.
- Following Alex's instructions, install the notifyme script on OS X, in e.g.
~/bin/notifyme(assuming ~/bin is in $PATH, remember tochmod u+x notifyme) - (Vagrant) Install Ruby on the VM:
sudo apt-get install ruby - (OS X) Install the vagrant-notify plugin:
vagrant plugin install vagrant-notify - (OS X) Restart the virtual machine:
vagrant halt&vagrant up - (OS X) Alias our script under a name which the plugin knows:
ln -s ~/bin/notifyme ~/bin/notify-send - (Vagrant) Append to the end of the
~/.zshrcin your Vagrant box:
function f_notifyme {
LAST_EXIT_CODE=$?
CMD=$(fc -ln -1)
# No point in waiting for the command to complete
notify-send "$CMD" "$LAST_EXIT_CODE" &
}
export PS1='$(f_notifyme)'$PS1
Fire up a new zsh shell, or do a source .zshrc, and you should get notifications of finished shell commands on your desktop!