Skip to content

Instantly share code, notes, and snippets.

@ecmendenhall
Last active August 29, 2015 14:03
Show Gist options
  • Save ecmendenhall/44df9db69c58a7f4dcbb to your computer and use it in GitHub Desktop.
Save ecmendenhall/44df9db69c58a7f4dcbb to your computer and use it in GitHub Desktop.
Unicornleap from a Vagrant VM (OS X)

Unicornleap from Vagrant (OS X)

The vagrant-notify plugin replaces the Linux notify-send command in your Vagrant VM with a Ruby script that forwards notifcations to the host machine. You can use it to invoke unicornleap when your specs pass. (Or, you know, whenever).

On the host

From the host machine, install vagrant-notify:

$ vagrant plugin install vagrant-notify

The notify-send utility is not included in OS X. By faking it with a shell script of the same name somewhere on your $PATH,you can make it run unicornleap. I put it in my ~/.bin directory.

~/.bin/notify-send

#! /bin/bash
unicornleap -s 1.618

Check that ~/.bin (or wherever you put the script) is on your $PATH with

$ echo $PATH

If not, add it in your .bashrc.

On the guest

Add a function to your .bashrc in the guest machine:

function specs() {
  if [ -n "$1" ]; then
    bundle exec rspec "$1" && notify-send
  else
    bundle exec rspec && notify-send
  fi
}

Now run

$ specs 

or

$ specs  path/to/spec.rb

Passing specs will invoke notify-send and call unicornleap on the host machine.

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