feat(shell): add scrollback history capture on shell exit #24
Reference in New Issue
Block a user
Delete Branch "feat/scrollback-history-on-exit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
smart_exitfunction — when running inside Kitty, closing an interactive shell withexitautomatically saves a timestamped scrollback snapshot to~/.terminal_history(orSCROLLBACK_HISTORY_DIR). Snapshots are pruned once the count exceedsSCROLLBACK_HISTORY_MAX_FILES(default 100). Pass--no-log/-nto exit without saving.config.fishwiring — exportsSCROLLBACK_HISTORY_DIRandSCROLLBACK_HISTORY_MAX_FILESwith safe defaults; wraps theexitbuiltin to route throughsmart_exitin interactive sessions.catANSI passthrough — detects files insideSCROLLBACK_HISTORY_DIRor containing raw ANSI escape sequences and passes them tocommand catinstead ofbat, so color output is preserved when reviewing saved scrollback logs.alias rm="rm -i"fromconf.d/tricks.fish; the trash-awarefunctions/rm.fishwrapper is the authoritative handler and the two conflicted.smart_exitadded to the System functions table,catdescription updated, stalermSafety Wrapper entry and its note removed.Manual Verification
exit— confirm ascrollback_*.logfile appears in~/.terminal_historyand contains the session output with ANSI sequences intact.exit --no-log— confirm the shell closes without creating a new log file.cat ~/.terminal_history/scrollback_<tab>— confirm the file renders with colors (not garbled by bat syntax highlighting).rm somefilein an interactive session — confirm you still get the trash-aware prompt fromfunctions/rm.fish(i.e., the alias removal did not break anything).SCROLLBACK_HISTORY_MAX_FILES=3inlocal.fish, open and close 4 sessions — confirm only 3 log files remain after the 4th exit.