diff options
author | Azat Bahawi <azat@bahawi.net> | 1970-01-01 03:00:00 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2022-09-20 11:57:34 +0300 |
commit | fcf8d0c0246b353f255eb5173cd8cd3748f8da3b (patch) | |
tree | 50717852ab2d895415a77b64462de4723322c404 /pts-reload |
Diffstat (limited to 'pts-reload')
-rwxr-xr-x | pts-reload | 33 |
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 |