Skip to content

cmus_queue_bottom_top

Blake Grotewold edited this page Mar 10, 2014 · 2 revisions

The idea behind this script is to move recently queued items back to the top without queue-editing. For prepending tracks to the queue you can select the desired song and hit E(standard shortcut)

 #!/bin/bash
 
# This program takes the bottom queued song and moves it to the top of the 
# queue
 
# Dump the queue to stdout and prepend 'add -q /' to each song so they can be
# added later
q=$(cmus-remote -C "save -q -" | sed "s/^/add -q /")
 
# Strip all the output except for the very last song
bottom_to_top=$(echo "$q" | tail -n 1)
 
# Remove only the very last line
body=$(echo "$q" | head -n -1)
 
# Clear the current queue. Add the previously bottom song, and then add the rest
(echo "clear -q"; echo "$bottom_to_top"; echo "$body") | cmus-remote