Skip to content

Instantly share code, notes, and snippets.

@tbeseda
Created March 24, 2014 18:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbeseda/9746123 to your computer and use it in GitHub Desktop.
Save tbeseda/9746123 to your computer and use it in GitHub Desktop.
Append current Rdio track to commit message
#!/usr/bin/ruby
message_file = ARGV[0]
def app_is_running?(app_name)
`ps aux` =~ /#{app_name}/ ? true : false
end
while true
if app_is_running?('Rdio.app')
artist = `osascript -e 'tell application "Rdio" to get the artist of the current track'`
track = `osascript -e 'tell application "Rdio" to get the name of the current track'`
File.open(message_file, 'a') do |file|
file.puts "\n♫ #{artist.chomp} - #{track.chomp}"
end
end
break
end
@tbeseda
Copy link
Author

tbeseda commented Mar 24, 2014

Add this file to .git/hooks/ and chmod 755 it.

Looks like this:

♫ Seasick Steve - Down On The Farm

@tbeseda
Copy link
Author

tbeseda commented Mar 24, 2014

@josephgrossberg
Copy link

You could also add this to a crontab, so it's asynchronous.

It's fast, but maybe the ps, osacript calls, and writing to the filesystem will slow down the responsiveness of your git commands?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment