Detect dark/light mode on the CLI.
Modern operating systems can automatically switch between dark and light mode. However, many CLI tools assume a fixed dark or light background unless told otherwise. This is an attempt to make that less painful.
The output is intentionally minimal; it just prints dark or light. This allows you to construct command lines with it. Examples:
fzf --color=$(dol)difft --background $(dol) file1 file2
Either of these will work.
mise use -g github:netmute/dolgo install github.com/netmute/dol@latest- dol writes a
CSI ? 996 ndevice status report (DSR) query to/dev/ttyand expects a reply likeCSI ? 997 ; 1 n(dark) orCSI ? 997 ; 2 n(light). - If your terminal does not support this query, dol prints an error and exits with status 1.
See this document to check whether your terminal currently supports this feature.