Skip to content

Instantly share code, notes, and snippets.

@ffd8
Last active May 18, 2020 21:38
Show Gist options
  • Save ffd8/3343c3f710652d559e34a9db286df204 to your computer and use it in GitHub Desktop.
Save ffd8/3343c3f710652d559e34a9db286df204 to your computer and use it in GitHub Desktop.
mp3dir - simple mp3 dir player for CLI
#!/bin/bash
# mp3dir
# cc teddavis.org 2020
# play dir of mp3's using afplay in MacOS terminal.
#
# install:
# `cd /usr/local/bin`
# `touch mp3dir`
# `open mp3dir`
# copy + paste these entire contents, save + close file
# `chmod +x mp3dir`
#
# use:
# `mp3dir *drag+drop dir*`
# enjoy!
#
# exit:
# `CTRL + C`
# use current dir, or if provided, cd to that dir
if [ "$#" -ne 0 ]
then
cd "$1"
fi
# loop through dir and play mp3's one after another
for i in *.mp3; do
if [ -e "$i" ]; then
afplay "$i"
fi
done
@ffd8
Copy link
Author

ffd8 commented May 18, 2020

mp3dir

Want a super basic mp3 player using your CLI interface (Terminal in MacOS)?
No need for pause/skip/scrub/like/etcetc?? Then mp3dir is for you!

install

Open Terminal (or CLI tool of choice), run the following commands one at a time:

  • cd /usr/local/bin // sets CLI working path to local binaries dir
  • touch mp3dir // creates blank file called mp3dir
  • open mp3dir // opens file in text editor
  • paste gist code above into text editor window, save, close
  • chmod +x mp3dir // makes executable

Alternatively, Download Zip above, open Terminal:

  • cd /usr/local/bin // sets CLI working path to local binaries dir
  • copy mp3dir file into folder
  • chmod +x mp3dir // makes executable

usage

  • mp3dir *drag+drop mp3 dir*
  • enjoy!

exit

  • CTRL + C // quits CLI process

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