Skip to content

cmus_randomize_queue

Blake Grotewold edited this page Mar 10, 2014 · 1 revision

Use this script to randomize the current queue!

#!/bin/bash
 
q=$(cmus-remote -C "save -q -" | sort -R | sed "s/^/add -q /")
(echo "clear -q" ; echo "$q" ) | cmus-remote

Note: sort -R randomly sorts matching lines together; it hashes each string and then sorts the hashes, and, since the hash of the same string is the same, duplicated songs are sorted next to each other which may not be the intended functionality. This potential problem could be fixed by replacing the sort with the perl one-liner perl -MList::Util -e 'print List::Util::shuffle <>' which calls a perl library shuffle.