feat(shell): add scrollback history capture on shell exit
- Add smart_exit function: captures Kitty scrollback to a timestamped log file on exit; --no-log/-n skips capture; auto-prunes oldest logs once count exceeds SCROLLBACK_HISTORY_MAX_FILES - Wire exit → smart_exit in config.fish for interactive sessions; export SCROLLBACK_HISTORY_DIR and SCROLLBACK_HISTORY_MAX_FILES with sane defaults (~/.terminal_history and 100 respectively) - Update cat to detect files in SCROLLBACK_HISTORY_DIR or containing raw ANSI escape sequences and pass them through command cat instead of bat, preserving color output - Remove redundant alias rm="rm -i" from tricks.fish (superseded by functions/rm.fish trash-aware wrapper) - Sync README: new Scrollback History integration section, smart_exit added to System functions table, cat description updated, stale rm Safety Wrapper entry and note removed
This commit is contained in:
+18
@@ -70,6 +70,24 @@ set -gx SUDO_EDITOR $EDITOR
|
||||
# Helps ensure that GPG can prompt for passphrases correctly when invoked from the terminal.
|
||||
set -gx GPG_TTY (tty)
|
||||
|
||||
# ────────────────────────── Scrollback History ──────────────────────────
|
||||
# Directory where scrollback history is saved into log files.
|
||||
set -gx SCROLLBACK_HISTORY_DIR "$HOME/.terminal_history"
|
||||
# Maximum number of scrollback history files to keep
|
||||
set -gx SCROLLBACK_HISTORY_MAX_FILES 100
|
||||
# Wire up a clean exit function that won't fire on background subshells
|
||||
if status is-interactive
|
||||
function exit --description 'Safe interactive exit'
|
||||
# If the smart_exit file exists in our function path, invoke it explicitly
|
||||
if functions -q smart_exit
|
||||
smart_exit $argv
|
||||
else
|
||||
# Absolute fallback to protect shell mechanics
|
||||
builtin exit $argv
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# ──────────────────────────── PATH variables ────────────────────────────
|
||||
# Adds common user bin directories to the PATH. The -mg --move option for cargo ensures that
|
||||
# the cargo bin directory is moved to the end of the PATH, which can help avoid conflicts
|
||||
|
||||
Reference in New Issue
Block a user