From 0f08d04698c814955116b6bae50752e64b774d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 23 Dec 2021 18:28:03 +0000 Subject: Thu Dec 23 06:28:03 PM UTC 2021 --- .bin/term-color | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 .bin/term-color (limited to '.bin/term-color') diff --git a/.bin/term-color b/.bin/term-color new file mode 100755 index 0000000..45a2dcc --- /dev/null +++ b/.bin/term-color @@ -0,0 +1,36 @@ +#!/bin/sh + +set -xe + +sequences="${HOME}/.config/dot/term-color" +cache_file="${HOME}/.cache/dot/sequences" + +if [ "${1}" = "-l" ]; then + sequences="${sequences}-light" +else + sequences="${sequences}-dark" +fi + +[ -f "${sequences}" ] + +case $(uname) in + OpenBSD) + ttys=$(ps | + tail -n +2 | + tr -s " " | + sed 's/^ //g' | + cut -d " " -f 2 | + sed 's/-$//g' | + uniq | + sed 's/^/\/dev\/tty/g') + ;; + Linux) + ttys=$(find /dev/pts -iname "[0-9]*") + ;; +esac + +for tty in $ttys; do + [ -c "${tty}" ] && cat "${sequences}" > $tty +done + +cp "${sequences}" "${cache_file}" -- cgit v1.2.3