I just threw together a quick little plugin, pretty trivial to implement, but useful to me, and figured it might be of interest to some.
This adds support for beets command aliases, not unlike git.
By default, it also checks $PATH for beet-* commands/scripts and makes those available as well.
Example configuration:
alias:
from_path: True # Default
aliases:
singletons: ls singleton:true
external-cmd-test: '!echo'
sh-c-test: '!sh -c "echo foo bar arg1:$1, arg2:$2" sh-c-test'
Example of the command listing the available aliases on my system:
$ beet alias
albums-for: !beet-albums-for
external-cmd-test: !echo
items-for: !beet-items-for
merge-albums: !beet-merge-albums
open: !beet-open
sh-c-test: !sh -c "echo foo bar arg1:$1, arg2:$2" sh-c-test
singletons: ls singleton:true
Using a couple aliases:
$ beet singletons | tail -n 1
[15394] The Tiberian Sons - Frank Klepacki & The Tiberian Sons LIVE: OFFICIAL Multi-cam Full Show
$ beet sh-c-test something something-else
foo bar arg1:something, arg2:something-else
$ beet external-cmd-test foo
foo
A less contrived example from my own configuration:
simple-dupe-check: "dup -Fa -k albumartist -k album -k disctotal -k tracktotal -f '[$id] $albumartist - $album - $existing/$albumtotal via $source'"
$ beet simple-dupe-check
[158] Dirty Vegas - Electric Love - 1/8 via Amazon
[624] Dirty Vegas - Electric Love - 1/10 via Google
[213] Langhorne Slim - Be Set Free - 1/1 via Amazon
[1659] Langhorne Slim - Be Set Free - 1/13 via iTunes
And my current entire config:
alias:
aliases:
reimport: import -maL
reimport-mb: reimport mb_albumid::'^$'
dup-albums: dup -aF
dup-a: dup-albums
singletons: ls singleton:true
# get-config library; get-config alias.aliases.reimport
get-config: '!sh -c "beet config | yq -r \".$1\"" -'
# Show incomplete albums, skipping any albums where I only have one track
incomplete-albums: 'ls -a -f "[$id] $albumartist - $album, $existing/$albumtotal, missing $missing tracks" missing:2.. single_track:false , missing:1 \\^genre:game \\^genre:videogame \\^genre:vgm single_track:false'
# Very basic dupe check for albums lacking musicbrainz data, primarily
simple-dupe-check: 'dup -Fa -k albumartist -k album -k disctotal -k tracktotal -f "[$id] $albumartist - $album - $existing/$albumtotal via $source"'
# Red flags
empty-artist: ls artist::'^$'
empty-album: ls album::'^$' singleton:false
book-not-audiobook: ls genre:book '^albumtype:audiobook'
unknown-source: source:Unknown
# Potential concerns
various-not-comp: ls -a is_various_not_comp:true
unknown-soundtracks: ls -f '$genre $path' albumtype:soundtrack \^genre:soundtrack \^genre:game
# Informative
non-mb-albums: ls -a mb_albumid::^$
possible-singles: ls -a tracktotal:1 'albumtype::^$'
# These are often not an issue, just albums which feature multiple
# artists, but aren't compilations. Cases where the album artist is the
# producer, cases where there are featuring artist, etc.
multiartist-not-comp: ls -a comp:false multiartist:true