about summary refs log tree commit diff
path: root/pts-reload
diff options
context:
space:
mode:
Diffstat (limited to 'pts-reload')
-rwxr-xr-xpts-reload33
1 files changed, 33 insertions, 0 deletions
diff --git a/pts-reload b/pts-reload
new file mode 100755
index 0000000..20b1e77
--- /dev/null
+++ b/pts-reload
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+if command -v xgetres >/dev/null 2>&1; then
+    declare BG FG
+    BG="$(xgetres background)"
+    FG="$(xgetres foreground)"
+
+    for i in {0..15}; do
+        # shellcheck disable=SC2140
+        declare "COLOR_${i}"="$(xgetres color"${i}")"
+    done
+
+    declare SEQ=
+    for i in {0..15}; do
+        COLOR="COLOR_${i}"
+        SEQ+="\\e]4;${i};${!COLOR}\\e\\\\"
+        unset "COLOR_${i}"
+    done
+    SEQ+="\\e]10;${FG}\\e\\\\"
+    SEQ+="\\e]11;${BG}\\e\\\\"
+    SEQ+="\\e]708;${BG}\\e\\\\"
+    SEQ+="\\e]12;${FG}\\e\\\\"
+    unset BG FG
+
+    shopt -s extglob
+
+    for i in /dev/pts/*[0-9]; do
+        if [ -w "${i}" ]; then
+            printf %b "${SEQ}" >"${i}"
+        fi
+    done
+    unset SEQ
+fi

Consider giving Nix/NixOS a try! <3