Skip to content

Instantly share code, notes, and snippets.

@koonix
Last active January 3, 2022 17:50
Show Gist options
  • Save koonix/353c058603027463cfff085db4e77875 to your computer and use it in GitHub Desktop.
Save koonix/353c058603027463cfff085db4e77875 to your computer and use it in GitHub Desktop.
Play music in terminal via mpv.
#!/bin/sh
clear -x; tput civis # hide cursor
mpv \
--audio-display=no --term-osd-bar --force-window=no \
--keep-open=yes --display-tags-clr --term-title='mpv' \
--msg-level=cplayer=error,ffmpeg=fatal,ffmpeg/demuxer=error \
--term-status-msg='File: ${filename}\n\nTitle: ${metadata/by-key/title}\nArtist: ${metadata/by-key/artist}\nAlbum: ${metadata/by-key/album}\n\n${!playlist-count==1:Playing ${playlist-pos-1}/${playlist-count}\n}${?pause==yes:(Paused) }${time-pos} / ${duration}' \
--term-osd-bar-chars='[-> ]' "$@"
tput cnorm # cursor back to normal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment