Skip to content

Instantly share code, notes, and snippets.

@willbuckner
Created September 4, 2016 05:07
Show Gist options
  • Save willbuckner/ad03bdc38706ecc35d781d166d8bb9d0 to your computer and use it in GitHub Desktop.
Save willbuckner/ad03bdc38706ecc35d781d166d8bb9d0 to your computer and use it in GitHub Desktop.
Control Spotify from Terminal on Mac OS
alias macdre='spotify spotify:artist:4sv6VJ2QZlaSosz3kFlxQH'
alias slaps="spotify $SPOTIFY_DEFAULT_PLAYLIST"
function spotify()
{
spotify_osa "play track \"$1\""
}
function spotify_osa()
{
SCRIPT="
tell application \"Spotify\"
$*
end tell
"
#echo "$SCRIPT"
osascript -e "$SCRIPT"
}
function track()
{
spotify_osa "
set trackArtist to artist of current track as string
set trackName to name of current track as string
set trackUrl to spotify url of current track as string
set output to (trackArtist & \" - \" & trackName & \" [ \" & trackUrl & \" ]\")
do shell script \"echo \" & quoted form of output
"
}
alias next='spotify_osa "next track"'
alias prev='spotify_osa "previous track"'
alias pause='spotify_osa "pause"'
alias play='spotify_osa "play"'
alias back='prev'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment