summary refs log tree commit diff
path: root/bin/term-apply-colors
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-11-18 18:07:38 +0100
committerRobert Günzler <r@gnzler.io>2022-11-18 18:38:21 +0100
commitf005fbf41646437964458d4c2028e6fdc04b59a1 (patch)
tree2db56c1d202137278c5642ed418123b882d35dc5 /bin/term-apply-colors
parent5e6e8da510836bbb0c7ac1602d51a394ba02ab2b (diff)
bin: add a few scripts
Diffstat (limited to 'bin/term-apply-colors')
-rwxr-xr-xbin/term-apply-colors18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/term-apply-colors b/bin/term-apply-colors
new file mode 100755
index 0000000..829ab4f
--- /dev/null
+++ b/bin/term-apply-colors
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+[ -n "$DEBUG" ] && set -x
+
+# stolen from https://github.com/lemnos/theme.sh/blob/master/bin/theme.sh
+awk '
+BEGIN {
+	fgesc="\033]10;#%s\007"
+	bgesc="\033]11;#%s\007"
+	curesc="\033]12;#%s\007"
+	colesc="\033]4;%d;#%s\007"
+}
+/^foreground:/ { printf fgesc, substr($2, 2) > "/dev/tty" }
+/^background:/ { printf bgesc, substr($2, 2) > "/dev/tty" }
+/^cursor:/ { printf curesc, substr($2, 2) > "/dev/tty" }
+/^[0-9]+:/ { printf colesc, $1, substr($2, 2) > "/dev/tty" }
+'