Skip to content

Commit 88bd8e1

Browse files
author
Phil Hindman
committed
Set/unset logging variable
Set it in start_pipe_pane, unset it in stop_pipe_pane, and determine whether logging is on by whether it is set or unset.
1 parent d99a25a commit 88bd8e1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/toggle_logging.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,31 @@ start_pipe_pane() {
1010
local file=$(expand_tmux_format_path "${logging_full_filename}")
1111
"$CURRENT_DIR/start_logging.sh" "${file}"
1212
display_message "Started logging to ${file}"
13+
set_logging_variable "logging"
1314
}
1415

1516
stop_pipe_pane() {
1617
tmux pipe-pane
1718
display_message "Ended logging to $logging_full_filename"
19+
unset_logging_variable
1820
}
1921

2022
# saving 'logging' 'not logging' status in a variable unique to pane
2123
set_logging_variable() {
2224
tmux set-option -pq @logging-variable "$1"
2325
}
2426

27+
unset_logging_variable() {
28+
tmux set-option -pu @logging-variable
29+
}
30+
2531
get_logging_variable() {
2632
tmux show-option -pqv @logging-variable
2733
}
2834

2935
# this function checks if logging is happening for the current pane
3036
is_logging() {
31-
if [ "$(get_logging_variable)" == "logging" ]; then
37+
if [ -n "$(get_logging_variable)" ]; then
3238
return 0
3339
else
3440
return 1
@@ -38,10 +44,8 @@ is_logging() {
3844
# starts/stop logging
3945
toggle_pipe_pane() {
4046
if is_logging; then
41-
set_logging_variable "not logging"
4247
stop_pipe_pane
4348
else
44-
set_logging_variable "logging"
4549
start_pipe_pane
4650
fi
4751
}

0 commit comments

Comments
 (0)