diff --git a/scripts/toggle_logging.sh b/scripts/toggle_logging.sh index e240d8c..c0939d9 100755 --- a/scripts/toggle_logging.sh +++ b/scripts/toggle_logging.sh @@ -9,31 +9,31 @@ source "$CURRENT_DIR/shared.sh" start_pipe_pane() { local file=$(expand_tmux_format_path "${logging_full_filename}") "$CURRENT_DIR/start_logging.sh" "${file}" - display_message "Started logging to ${logging_full_filename}" + display_message "Started logging to ${file}" + set_active_logging_filename "${file}" } stop_pipe_pane() { tmux pipe-pane - display_message "Ended logging to $logging_full_filename" + display_message "Ended logging to $(get_active_logging_filename)" + unset_active_logging_filename } -# returns a string unique to current pane -pane_unique_id() { - tmux display-message -p "#{session_name}_#{window_index}_#{pane_index}" +set_active_logging_filename() { + tmux set-option -pq @active-logging-filename "$1" } -# saving 'logging' 'not logging' status in a variable unique to pane -set_logging_variable() { - local value="$1" - local pane_unique_id="$(pane_unique_id)" - tmux set-option -gq "@${pane_unique_id}" "$value" +unset_active_logging_filename() { + tmux set-option -pu @active-logging-filename +} + +get_active_logging_filename() { + tmux show-option -pqv @active-logging-filename } # this function checks if logging is happening for the current pane is_logging() { - local pane_unique_id="$(pane_unique_id)" - local current_pane_logging="$(get_tmux_option "@${pane_unique_id}" "not logging")" - if [ "$current_pane_logging" == "logging" ]; then + if [ -n "$(get_active_logging_filename)" ]; then return 0 else return 1 @@ -43,10 +43,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 }