From a68ee0a52fba94a8bec347584b3e752194f6ec62 Mon Sep 17 00:00:00 2001 From: Phil Hindman Date: Thu, 16 May 2024 22:53:03 -0500 Subject: [PATCH] Save logging filename in pane-specific variable When logging is started, save the name of the log file in the variable. When logging is stopped, use the variable to display the name of the file, then clear the variable. Use whether the variable is empty or not to determine if logging has been started. --- scripts/toggle_logging.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/toggle_logging.sh b/scripts/toggle_logging.sh index 415a0d9..51b7695 100755 --- a/scripts/toggle_logging.sh +++ b/scripts/toggle_logging.sh @@ -10,11 +10,13 @@ start_pipe_pane() { local file=$(expand_tmux_format_path "${logging_full_filename}") "$CURRENT_DIR/start_logging.sh" "${file}" display_message "Started logging to ${file}" + set_logging_variable "${file}" } stop_pipe_pane() { tmux pipe-pane - display_message "Ended logging to $logging_full_filename" + display_message "Ended logging to $(get_logging_variable)" + set_logging_variable "" } # returns a string unique to current pane @@ -22,7 +24,7 @@ pane_unique_id() { tmux display-message -p "#{session_name}_#{window_index}_#{pane_index}" } -# saving 'logging' 'not logging' status in a variable unique to pane +# saving value in a variable unique to pane set_logging_variable() { local value="$1" local pane_unique_id="$(pane_unique_id)" @@ -31,13 +33,13 @@ set_logging_variable() { get_logging_variable() { local pane_unique_id="$(pane_unique_id)" - local current_pane_logging="$(get_tmux_option "@${pane_unique_id}" "not logging")" + local current_pane_logging="$(get_tmux_option "@${pane_unique_id}")" echo $current_pane_logging } # this function checks if logging is happening for the current pane is_logging() { - if [ "$(get_logging_variable)" == "logging" ]; then + if [ -n "$(get_logging_variable)" ]; then return 0 else return 1 @@ -47,10 +49,8 @@ is_logging() { # starts/stop logging toggle_pipe_pane() { if is_logging; then - set_logging_variable "not logging" stop_pipe_pane else - set_logging_variable "logging" start_pipe_pane fi }