-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathtoggle_logging.sh
More file actions
executable file
·57 lines (46 loc) · 1.09 KB
/
toggle_logging.sh
File metadata and controls
executable file
·57 lines (46 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/variables.sh"
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 ${file}"
set_active_logging_filename "${file}"
}
stop_pipe_pane() {
tmux pipe-pane
display_message "Ended logging to $(get_active_logging_filename)"
unset_active_logging_filename
}
set_active_logging_filename() {
tmux set-option -pq @active-logging-filename "$1"
}
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() {
if [ -n "$(get_active_logging_filename)" ]; then
return 0
else
return 1
fi
}
# starts/stop logging
toggle_pipe_pane() {
if is_logging; then
stop_pipe_pane
else
start_pipe_pane
fi
}
main() {
if supported_tmux_version_ok; then
toggle_pipe_pane
fi
}
main