Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials
Created July 7, 2015 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtfaremyinitials/140f28be294b5e8bd2d1 to your computer and use it in GitHub Desktop.
Save wtfaremyinitials/140f28be294b5e8bd2d1 to your computer and use it in GitHub Desktop.
Play any song in your iTunes library from the CLI
#!/usr/bin/env osascript -l JavaScript
function run(argv) {
if(argv.length == 0) {
console.log('Usage: play [ track ]');
} else {
Application('iTunes').playlists[0].tracks.whose({ name: { _contains: argv.join(' ') } })[0].play();
}
ObjC.import("stdlib")
$.exit(0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment