Skip to content

Instantly share code, notes, and snippets.

@cumulus13
Last active July 2, 2025 02:15
Show Gist options
  • Save cumulus13/209754c3e41d01ac8e8024b5164cdc8d to your computer and use it in GitHub Desktop.
Save cumulus13/209754c3e41d01ac8e8024b5164cdc8d to your computer and use it in GitHub Desktop.
[Batch] MPD show current playlist and current playing with colors
@echo off
setlocal enabledelayedexpansion
chcp 65001 >nul
:: Define ANSI color codes with proper escape character
for /f %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
set "RESET=%ESC%[0m"
set "BOLD=%ESC%[1m"
set "DIM=%ESC%[2m"
set "YELLOW_BG=%ESC%[43m%ESC%[30m"
set "GREEN=%ESC%[32m"
set "BLUE=%ESC%[34m"
set "CYAN=%ESC%[36m"
set "MAGENTA=%ESC%[35m"
set "RED=%ESC%[31m"
set "WHITE=%ESC%[37m"
set "GRAY=%ESC%[90m"
set "YELLOW=%ESC%[93m"
:: Icons (using Unicode characters)
set "PLAY_ICON=▶"
set "MUSIC_ICON=♫"
set "LIST_ICON=♪"
set "CURRENT_ICON=►"
:: Header
echo.
echo %CYAN%%BOLD%════════════════════════════════════════════════════════════════%RESET%
echo %CYAN%%BOLD% %MUSIC_ICON% MPC PLAYLIST %MUSIC_ICON% %RESET%
echo %CYAN%%BOLD%════════════════════════════════════════════════════════════════%RESET%
echo.
:: Get current playing song info
for /f "tokens=*" %%C in ('mpc current 2^>nul') do set "current_song=%%C"
if "%current_song%"=="" (
echo %RED%No song currently playing%RESET%
echo.
) else (
echo %GREEN%%BOLD%Currently Playing:%RESET% %YELLOW_BG%%BOLD% %PLAY_ICON% %current_song% %RESET%
echo.
)
:: Get playlist and display with colors and icons
set n=0
echo %BLUE%%BOLD%Playlist:%RESET%
echo %GRAY%────────────────────────────────────────────────────────────────%RESET%
for /f "tokens=*" %%A in ('mpc playlist 2^>nul') do (
set /a n+=1
set "song=%%A"
:: Check if this is the current playing song
if "!song!"=="%current_song%" (
:: Current playing song - yellow background
echo %YELLOW_BG%%BOLD%!n!. %CURRENT_ICON% !song!%RESET%
) else (
:: Regular playlist items with alternating colors
set /a "mod=!n! %% 3"
if !mod!==1 (
echo %BLUE%!n!. %LIST_ICON% !song!%RESET%
) else if !mod!==2 (
echo %MAGENTA%!n!. %LIST_ICON% !song!%RESET%
) else (
echo %CYAN%!n!. %LIST_ICON% !song!%RESET%
)
)
)
:: Footer
echo.
echo %GRAY%────────────────────────────────────────────────────────────────%RESET%
if %n%==0 (
echo %RED%%BOLD%Playlist is empty%RESET%
) else (
echo %GREEN%%BOLD%Total songs: %n%%RESET%
)
echo %CYAN%%BOLD%════════════════════════════════════════════════════════════════%RESET%
echo.
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment