Play MP3’s and other music from the command line
October 27th, 2009 - Command Line, How to, Tips & Tricks
Ever wanted to play music while you’re working in the command line? With the command line tool ‘afplay’ you can do just that, you can play practically any audio file from the Terminal, just type:
afplay /path/to/audiofile.mp3
You can then stop it with Control-C, otherwise the song will play itself through then terminate. If you’d rather afplay run in the background while playing audio, use this command:
afplay /path/to/audiofile.mp3 &
This launches afplay into the background, if you want to shut it up you can just kill the process with:
killall afplay
Not that I’m condoning this type of behavior, but I recently used the afplay command to play a pretty amusing prank on a coworker by SSHing into his work machine and forcing him to listen to a Miley Cyrus song, he didn’t figure out what was going on until it was over and I told him.
Posted by: Paul Horowitz

Order Mac OS X 10.6 Snow Leopard today from Amazon.com - $25!

Write a comment