Skip to content

Instantly share code, notes, and snippets.

@floere
Created September 12, 2012 18:36
Show Gist options
  • Save floere/3708935 to your computer and use it in GitHub Desktop.
Save floere/3708935 to your computer and use it in GitHub Desktop.
A better iTunes
#!/usr/bin/env ruby
#
# Usage:
# p [pattern ...]
#
# Example:
# p E*.mp3 pop/A*.mp3
#
files = Dir[ARGV.shift || '*.mp3', *ARGV].shuffle
puts "Next song: Ctrl-C."
puts "Exit: Ctrl-C twice, quickly."
puts
interrupts = 0
Signal.trap('INT') do
exit if interrupts > 0
interrupts += 1
sleep 0.1
interrupts = 0
end
files.each do |file|
puts file
%x{afplay "#{file}"}
end
@tonini
Copy link

tonini commented Sep 12, 2012

woooot! ;)

@floere
Copy link
Author

floere commented Sep 12, 2012

:)
Add a .cycle after the shuffle, if you want it to loop forever.

@niko
Copy link

niko commented Sep 12, 2012

What happened to good old mpg123? :)

@floere
Copy link
Author

floere commented Sep 12, 2012

It won't support Picky in the future ;)

@andykitchen
Copy link

I've been using BashTunes:

find . -name *.mp3 | xargs afplay

@floere
Copy link
Author

floere commented Sep 23, 2012

I like it!

@rogerbraun
Copy link

But does it really whip the llama's ass? If not, I'll stay with Winamp.

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