New smart_exit function — when running inside Kitty, closing an interactive shell with exit automatically saves a timestamped scrollback snapshot to ~/.terminal_history (or SCROLLBACK_HISTORY_DIR). Snapshots are pruned once the count exceeds SCROLLBACK_HISTORY_MAX_FILES (default 100). Pass --no-log / -n to exit without saving.
config.fish wiring — exports SCROLLBACK_HISTORY_DIR and SCROLLBACK_HISTORY_MAX_FILES with safe defaults; wraps the exit builtin to route through smart_exit in interactive sessions.
cat ANSI passthrough — detects files inside SCROLLBACK_HISTORY_DIR or containing raw ANSI escape sequences and passes them to command cat instead of bat, so color output is preserved when reviewing saved scrollback logs.
Cleanup — removes the redundant alias rm="rm -i" from conf.d/tricks.fish; the trash-aware functions/rm.fish wrapper is the authoritative handler and the two conflicted.
README sync — new Scrollback History integration section, smart_exit added to the System functions table, cat description updated, stale rm Safety Wrapper entry and its note removed.
Manual Verification
Open a Kitty terminal, run a few commands, then type exit — confirm a scrollback_*.log file appears in ~/.terminal_history and contains the session output with ANSI sequences intact.
Run 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).
Run rm somefile in an interactive session — confirm you still get the trash-aware prompt from functions/rm.fish (i.e., the alias removal did not break anything).
Check SCROLLBACK_HISTORY_MAX_FILES=3 in local.fish, open and close 4 sessions — confirm only 3 log files remain after the 4th exit.
## Summary
- **New `smart_exit` function** — when running inside Kitty, closing an interactive shell with `exit` automatically saves a timestamped scrollback snapshot to `~/.terminal_history` (or `SCROLLBACK_HISTORY_DIR`). Snapshots are pruned once the count exceeds `SCROLLBACK_HISTORY_MAX_FILES` (default 100). Pass `--no-log` / `-n` to exit without saving.
- **`config.fish` wiring** — exports `SCROLLBACK_HISTORY_DIR` and `SCROLLBACK_HISTORY_MAX_FILES` with safe defaults; wraps the `exit` builtin to route through `smart_exit` in interactive sessions.
- **`cat` ANSI passthrough** — detects files inside `SCROLLBACK_HISTORY_DIR` or containing raw ANSI escape sequences and passes them to `command cat` instead of `bat`, so color output is preserved when reviewing saved scrollback logs.
- **Cleanup** — removes the redundant `alias rm="rm -i"` from `conf.d/tricks.fish`; the trash-aware `functions/rm.fish` wrapper is the authoritative handler and the two conflicted.
- **README sync** — new _Scrollback History_ integration section, `smart_exit` added to the System functions table, `cat` description updated, stale `rm` Safety Wrapper entry and its note removed.
## Manual Verification
- [x] Open a Kitty terminal, run a few commands, then type `exit` — confirm a `scrollback_*.log` file appears in `~/.terminal_history` and contains the session output with ANSI sequences intact.
- [x] Run `exit --no-log` — confirm the shell closes without creating a new log file.
- [x] `cat ~/.terminal_history/scrollback_<tab>` — confirm the file renders with colors (not garbled by bat syntax highlighting).
- [x] Run `rm somefile` in an interactive session — confirm you still get the trash-aware prompt from `functions/rm.fish` (i.e., the alias removal did not break anything).
- [x] Check `SCROLLBACK_HISTORY_MAX_FILES=3` in `local.fish`, open and close 4 sessions — confirm only 3 log files remain after the 4th 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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.