Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure correct filename is displayed in Start/Stop messages #69

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions scripts/toggle_logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down