Skip to content

Instantly share code, notes, and snippets.

@kevinmcconnell
Created June 16, 2014 21:26
Show Gist options
  • Save kevinmcconnell/09b71ad588e0939dbe7e to your computer and use it in GitHub Desktop.
Save kevinmcconnell/09b71ad588e0939dbe7e to your computer and use it in GitHub Desktop.
Annotate your git commits with the song that's current playing in iTunes
#!/usr/bin/env ruby
def get_current_song
`osascript \
-e 'tell application "iTunes"' \
-e '"♪ " & (get name of current track) & " - " & (get artist of current track) & " ♪"' \
-e 'end tell' 2>/dev/null`
end
def append_current_song_if_present
current_song = get_current_song
unless current_song.empty?
open(ARGV[0], 'r+') do |f|
current_message = f.read()
f.rewind
f.write "\n\n----\n#{current_song}\n"
f.write current_message
f.close
end
end
end
append_current_song_if_present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment