feat(c5): add tmux pipe-pane session logging
Starts tmux pipe-pane capture for the current pane whenever fish launches inside a tmux session. Each shell gets a timestamped log in SCROLLBACK_HISTORY_DIR. Toggling __fish_config_op_logging stops or restarts the pipe in all open fish shells via the existing --on-variable event handlers.
This commit is contained in:
@@ -6,8 +6,9 @@
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Synchronises C5 logging state: creates or removes the Kitty sentinel
|
||||
# file ($XDG_CONFIG_HOME/fish/.logging_disabled) and generates or removes
|
||||
# the paru/yay AUR-helper log wrappers based on the combined value of
|
||||
# file ($XDG_CONFIG_HOME/fish/.logging_disabled), generates or removes the
|
||||
# paru/yay AUR-helper log wrappers, and starts or stops tmux pipe-pane
|
||||
# capture for the current pane — all based on the combined value of
|
||||
# __fish_config_opinionated (master) and __fish_config_op_logging (C5).
|
||||
# Called by --on-variable event handlers whenever either variable changes.
|
||||
# Safe to call at any time; wrapper removal only affects files bearing
|
||||
@@ -32,6 +33,15 @@ function __fish_config_sync_logging --description 'Sync C5 logging state: sentin
|
||||
# Logging enabled: remove sentinel and regenerate wrappers if binaries exist
|
||||
rm -f $sentinel
|
||||
|
||||
# Restart tmux pipe-pane for the current pane if inside tmux
|
||||
if set -q TMUX
|
||||
set -l log_dir (set -q SCROLLBACK_HISTORY_DIR; and echo $SCROLLBACK_HISTORY_DIR; or echo "$HOME/.terminal_history")
|
||||
set -l pane_id (tmux display-message -p '#{session_name}-w#{window_index}-p#{pane_index}' 2>/dev/null)
|
||||
set -l timestamp (date "+%Y-%m-%d_%H-%M-%S")
|
||||
mkdir -p $log_dir
|
||||
tmux pipe-pane "cat >> $log_dir/tmux_${pane_id}_${timestamp}.log" 2>/dev/null
|
||||
end
|
||||
|
||||
if test -x /usr/bin/paru
|
||||
mkdir -p (dirname $paru_wrapper)
|
||||
printf '%s\n' \
|
||||
@@ -95,5 +105,10 @@ function __fish_config_sync_logging --description 'Sync C5 logging state: sentin
|
||||
and grep -q "# yay-wrapper-version:" $yay_wrapper 2>/dev/null
|
||||
rm -f $yay_wrapper
|
||||
end
|
||||
|
||||
# Stop tmux pipe-pane for the current pane if inside tmux
|
||||
if set -q TMUX
|
||||
tmux pipe-pane 2>/dev/null
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user