Skip to content

Instantly share code, notes, and snippets.

@agrberg
Created December 5, 2014 16:35
Show Gist options
  • Save agrberg/7a09dea9a4ac545decb7 to your computer and use it in GitHub Desktop.
Save agrberg/7a09dea9a4ac545decb7 to your computer and use it in GitHub Desktop.
Helpers for `afplay` OS X
function pid_for_name() {
ps -A | grep -m1 $1 | awk '{print $1}'
}
function pause_af {
kill -17 $(pid_for_name afplay)
}
function play_af {
kill -19 $(pid_for_name afplay)
}
@cityismychurch
Copy link

This wasn't working for me, I had to:

function pid_for_name() {
ps -A | grep -m2 $1 | tail -1 | awk '{print $1}'
}

I don't know why our systems would report the grep process and afplay in a different order.

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