Skip to content

Instantly share code, notes, and snippets.

@kristianfreeman
Forked from fholgado/.tmux.conf
Created December 9, 2012 07:26
Show Gist options
  • Save kristianfreeman/4243765 to your computer and use it in GitHub Desktop.
Save kristianfreeman/4243765 to your computer and use it in GitHub Desktop.
Show iTunes current track/song in tmux
# Custom status bar
# # Powerline symbols: ⮂ ⮃ ⮀ ⮁ ⭤
set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 5
set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]⮀'
set -g status-right '#[fg=colour245]⮃ %R ⮃ %d %b #[fg=colour254,bg=colour234,nobold]#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)⮂#[fg=colour16,bg=colour254,bold] #h '
# set -g status-right '#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)'
set -g window-status-format "#[fg=white,bg=colour234] #I #W "
set -g window-status-current-format "#[fg=colour234,bg=colour39]⮀#[fg=colour16,g=colour39,noreverse,bold] #I ⮁ #W #[fg=colour39,bg=colour234,nobold]⮀"
1. Place itunes-current-track-tmux.sh somewhere nice.
2. Make it executable by doing "chmod +x itunes-current-track-tmux.sh"
3. Place the contents of .tmux.conf inside your own .tmux.conf
4. Adjust the path in this line to match where you placed the shell script:
set -g status-right '#[fg=colour245]⮃ %R ⮃ %d %b #[fg=colour254,bg=colour234,nobold]#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)⮂#[fg=colour16,bg=colour254,bold] #h '
5. Restart tmux with "killall -9 tmux"
6. Fire up iTunes, tmux, and enjoy! Screenshot here: http://f.fhl.gd/En8X
#!/usr/bin/env bash
ITUNES_TRACK=$(osascript <<EOF
if appIsRunning("Spotify")
tell app "Spotify" to get the name of the current track
else if appIsRunning("iTunes") then
tell app "iTunes" to get the name of the current track
end if
on appIsRunning(appName)
tell app "System Events" to (name of processes) contains appName
end appIsRunning
EOF)
if test "x$ITUNES_TRACK" != "x"; then
ITUNES_ARTIST=$(osascript <<EOF
if appIsRunning("Spotify")
tell app "Spotify" to get the artist of the current track
else if appIsRunning("iTunes") then
tell app "iTunes" to get the artist of the current track
end if
on appIsRunning(appName)
tell app "System Events" to (name of processes) contains appName
end appIsRunning
EOF)
echo '#[fg=colour137,bg=colour234]⮂#[bg=colour137,fg=colour16,bold] ♫' $ITUNES_TRACK '#[nobold]by#[bold]' $ITUNES_ARTIST '#[fg=colour254,bg=colour137,nobold]'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment