From 08a274af6bc15c77f450d552416a3983fc6c02a4 Mon Sep 17 00:00:00 2001 From: Phil Hindman Date: Sat, 28 Sep 2024 23:40:48 -0500 Subject: [PATCH 1/2] Stop temporarily overriding display-time Pass the desired display time to display-message using the -d option instead of temporarily overriding the user's chosen display-time. --- scripts/shared.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/shared.sh b/scripts/shared.sh index 8b316d1..d8df707 100644 --- a/scripts/shared.sh +++ b/scripts/shared.sh @@ -20,17 +20,7 @@ display_message() { local display_duration="5000" fi - # saves user-set 'display-time' option - local saved_display_time=$(get_tmux_option "display-time" "750") - - # sets message display time to 5 seconds - tmux set-option -gq display-time "$display_duration" - - # displays message - tmux display-message "$message" - - # restores original 'display-time' value - tmux set-option -gq display-time "$saved_display_time" + tmux display-message -d $display_duration "$message" } # simplest solution, taken from here: http://unix.stackexchange.com/a/81689 From 25cf980ce468883289c9c069efad0f6e0adf4c4c Mon Sep 17 00:00:00 2001 From: Phil Hindman Date: Sat, 28 Sep 2024 23:40:48 -0500 Subject: [PATCH 2/2] Display messages for the user's display-time No callers pass a value for the second parameter, so it would always display the message for 5 seconds. Instead, respect the user's chosen value for display-time. --- scripts/shared.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/shared.sh b/scripts/shared.sh index d8df707..9630d4d 100644 --- a/scripts/shared.sh +++ b/scripts/shared.sh @@ -9,18 +9,8 @@ get_tmux_option() { fi } -# Ensures a message is displayed for 5 seconds in tmux prompt display_message() { - local message=$1 - - # display_duration defaults to 5 seconds, if not passed as an argument - if [ "$#" -eq 2 ]; then - local display_duration=$2 - else - local display_duration="5000" - fi - - tmux display-message -d $display_duration "$message" + tmux display-message "$1" } # simplest solution, taken from here: http://unix.stackexchange.com/a/81689