Skip to content

Instantly share code, notes, and snippets.

@BenjaminLawson
Last active April 4, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminLawson/9eb814049d48b4b806f8f57c0e8b8650 to your computer and use it in GitHub Desktop.
Save BenjaminLawson/9eb814049d48b4b806f8f57c0e8b8650 to your computer and use it in GitHub Desktop.
Shell script to replace mpd's playlist with the results of a Beets query
#!/usr/bin/env bash
# Replace the mpd playlist with the results of a Beets query
# Usage: 'bmpc QUERY'
# change BEETS_DIR to the name of your beets music directory
BEETS_DIR="beets"
RESULTS=$(beet ls -f '$path' "$@" | sed "s/.*\/$BEETS_DIR\///")
printf "$RESULTS\n\n"
mpc clear >/dev/null
printf "$RESULTS" | mpc add
mpc play
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment