summary refs log tree commit diff
path: root/bin/term-apply-colors
diff options
context:
space:
mode:
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" }
+'