summaryrefslogtreecommitdiffstats
path: root/.bin/term-color
blob: 45a2dccfed518340d1938a5df846ecf7e35d549a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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}"
remember that computers suck.