Created
June 16, 2014 21:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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