diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-12-23 18:28:03 +0000 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-12-23 18:28:03 +0000 |
commit | 0f08d04698c814955116b6bae50752e64b774d8f (patch) | |
tree | 8cf9a33557093eebfd25aab2872e97639c7e2f62 /.bin/term-color | |
download | dots-0f08d04698c814955116b6bae50752e64b774d8f.tar.gz |
Thu Dec 23 06:28:03 PM UTC 2021
Diffstat (limited to '.bin/term-color')
-rwxr-xr-x | .bin/term-color | 36 |
1 files changed, 36 insertions, 0 deletions
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}" |