From 95ba3ab7505872ef33e200dbf8c363c120cfb719 Mon Sep 17 00:00:00 2001 From: a <> Date: Tue, 15 Nov 2022 13:34:56 -0500 Subject: [PATCH 1/2] Workaround startup lag by suppressing visual effects --- tmux-thumbs.sh | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index 7e060e8..89e5738 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -18,13 +18,21 @@ elif [[ $(${THUMBS_BINARY} --version) != "thumbs ${VERSION}" ]]; then fi function get-opt-value() { - tmux show -vg "@thumbs-${1}" 2> /dev/null + tmux show -vg "${1}" 2> /dev/null +} + +function get-thumb-opt-value() { + get-opt-value "@thumbs-${1}" +} + +function set-opt-value() { + tmux set -g "${1}" "${2}" 2> /dev/null } function get-opt-arg() { local opt type value opt="${1}"; type="${2}" - value="$(get-opt-value "${opt}")" || true + value="$(get-thumb-opt-value "${opt}")" || true if [ "${type}" = string ]; then [ -n "${value}" ] && echo "--${opt}=${value}" @@ -45,6 +53,30 @@ function add-param() { fi } +# Temporarily suppress tmux visual effects to work around display lag. +function suppress-visual-effects() { + opt_va="visual-activity" + opt_vb="visual-bell" + opt_vs="visual-silence" + opt_va_val=$(get-opt-value "${opt_va}") + opt_vb_val=$(get-opt-value "${opt_vb}") + opt_vs_val=$(get-opt-value "${opt_vs}") + + function cleanup { + set-opt-value "${opt_va}" "${opt_va_val}" + set-opt-value "${opt_vb}" "${opt_vb_val}" + set-opt-value "${opt_vs}" "${opt_vs_val}" + } + trap cleanup EXIT + + # https://github.com/fcsonline/tmux-thumbs/issues/88#issuecomment-871516639 + set-opt-value "${opt_va}" off + set-opt-value "${opt_vb}" off + set-opt-value "${opt_vs}" on +} + +suppress-visual-effects + add-param command string add-param upcase-command string add-param multi-command string From 25e17d679ba001ed55072ebfa256ffdac234f92b Mon Sep 17 00:00:00 2001 From: a <> Date: Tue, 15 Nov 2022 14:01:14 -0500 Subject: [PATCH 2/2] Workaround startup lag by suppressing activity monitoring in pane. --- tmux-thumbs.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index 89e5738..0507997 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -18,7 +18,7 @@ elif [[ $(${THUMBS_BINARY} --version) != "thumbs ${VERSION}" ]]; then fi function get-opt-value() { - tmux show -vg "${1}" 2> /dev/null + tmux show -v "${2:-g}" "${1}" 2> /dev/null } function get-thumb-opt-value() { @@ -26,7 +26,7 @@ function get-thumb-opt-value() { } function set-opt-value() { - tmux set -g "${1}" "${2}" 2> /dev/null + tmux set "${3:-g}" "${1}" "${2}" 2> /dev/null } function get-opt-arg() { @@ -55,24 +55,28 @@ function add-param() { # Temporarily suppress tmux visual effects to work around display lag. function suppress-visual-effects() { + opt_ma="monitor-activity" opt_va="visual-activity" opt_vb="visual-bell" opt_vs="visual-silence" - opt_va_val=$(get-opt-value "${opt_va}") - opt_vb_val=$(get-opt-value "${opt_vb}") - opt_vs_val=$(get-opt-value "${opt_vs}") + opt_ma_val=$(get-opt-value "${opt_ma}" -p) + opt_va_val=$(get-opt-value "${opt_va}" -p) + opt_vb_val=$(get-opt-value "${opt_vb}" -p) + opt_vs_val=$(get-opt-value "${opt_vs}" -p) function cleanup { - set-opt-value "${opt_va}" "${opt_va_val}" - set-opt-value "${opt_vb}" "${opt_vb_val}" - set-opt-value "${opt_vs}" "${opt_vs_val}" + set-opt-value "${opt_ma}" "${opt_ma_val}" -p + set-opt-value "${opt_va}" "${opt_va_val}" -p + set-opt-value "${opt_vb}" "${opt_vb_val}" -p + set-opt-value "${opt_vs}" "${opt_vs_val}" -p } trap cleanup EXIT # https://github.com/fcsonline/tmux-thumbs/issues/88#issuecomment-871516639 - set-opt-value "${opt_va}" off - set-opt-value "${opt_vb}" off - set-opt-value "${opt_vs}" on + set-opt-value "${opt_ma}" off -p + set-opt-value "${opt_va}" off -p + set-opt-value "${opt_vb}" off -p + set-opt-value "${opt_vs}" on -p } suppress-visual-effects