Please enable JS

Trigger Spotify to play song via the CLI

Need a productivity boost? Play your pump up song from the CLI
March 28/Brian Young/Software

Mac's OSA Script is pretty neat. It's a handy way of controlling applications on your machine programmatically.

To get Spotify to play a song with a simple command, paste the following into your ~/.bash_aliases file.

  1. alias pump="osascript -e 'tell application \"Spotify\" to play track \"spotify:track:3KliPMvk1EvFZu9cvkj8p1\"' end tell"

You can copy the "Spotify URI" of any song by right-clicking the track in Spotify.

Start a new terminal session, then type: pump. Your song should start playing!



RELATED POSTS


Comments/ 0


LEAVE A COMMENT

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
But why?

My random thoughts and documentation on the various hardware and software projects that occupy my day-to-day. My only hope is that other people can benefit from my notes.

Recent posts
Categories