aliquote.org

August 27, 2025

Now playing from Apple Music right into Tmux status line!

img

Put this script somewhere in your $PATH:

#!/bin/sh
unset title

title=$(osascript -e 'if application "Music" is running then' -e 'tell application "Music" to get name of current track' -e 'end if')
artist=$(osascript -e 'if application "Music" is running then' -e 'tell application "Music" to get artist of current track' -e 'end if')

if ${title+"true"}; then echo "$artist$title"; fi

If you don’t mind using the -e switch as your line separator; otherwise just write a .scpt file and load it directly.

See this gist for a more elaborated solution that accounts for both Cmus and Apple Music.