Adds watcher.py — a kitty Python watcher that captures terminal scrollback to ~/.terminal_history/ on every window or pane close, regardless of how the terminal is closed (Ctrl+D, keybind, clicking X, full kitty quit)
Fixes kitty.conf watcher directive: removes invalid --type=global prefix that caused a FileNotFoundError on every kitty startup, meaning the watcher was never loaded
Documents the scrollback feature and its two configurable env vars in README.md
How it works
Two components handle logging:
fish smart_exit (existing) — intercepts graceful exit calls, logs scrollback via kitty @, and sets logged_by_shell=true on the window to signal the Python watcher to skip it
watcher.py (new) — registers on_close (fires per window on destruction) and on_quit (fires when kitty quits, iterates all windows) hooks; skips windows already logged by the shell or already logged in this session
Manual Verification
Restart kitty fully and confirm no watcher errors in journalctl --user _COMM=kitty
Open a pane, run some commands, close it with Ctrl+D — verify a new scrollback_*.log appears in ~/.terminal_history/
Close a pane via kitty keybind (not shell exit) — verify a log is created
Close a full kitty window (multiple panes) — verify one log per pane appears
Run exit in a fish shell — verify only one log is created (not duplicated by both fish and watcher)
## Summary
- Adds `watcher.py` — a kitty Python watcher that captures terminal scrollback to `~/.terminal_history/` on every window or pane close, regardless of how the terminal is closed (Ctrl+D, keybind, clicking X, full kitty quit)
- Fixes `kitty.conf` watcher directive: removes invalid `--type=global` prefix that caused a `FileNotFoundError` on every kitty startup, meaning the watcher was never loaded
- Documents the scrollback feature and its two configurable env vars in `README.md`
## How it works
Two components handle logging:
1. **fish `smart_exit`** (existing) — intercepts graceful `exit` calls, logs scrollback via `kitty @`, and sets `logged_by_shell=true` on the window to signal the Python watcher to skip it
2. **`watcher.py`** (new) — registers `on_close` (fires per window on destruction) and `on_quit` (fires when kitty quits, iterates all windows) hooks; skips windows already logged by the shell or already logged in this session
## Manual Verification
- [x] Restart kitty fully and confirm no watcher errors in `journalctl --user _COMM=kitty`
- [x] Open a pane, run some commands, close it with `Ctrl+D` — verify a new `scrollback_*.log` appears in `~/.terminal_history/`
- [x] Close a pane via kitty keybind (not shell exit) — verify a log is created
- [x] Close a full kitty window (multiple panes) — verify one log per pane appears
- [x] Run `exit` in a fish shell — verify only one log is created (not duplicated by both fish and watcher)
Introduces watcher.py — a kitty Python watcher that captures terminal
scrollback to ~/.terminal_history/ whenever any window or pane is closed
via Ctrl+D, keybind, or full kitty quit. Works alongside the fish
smart_exit function, which handles graceful shell exits and sets a
user var flag to prevent duplicate logs.
Fixes the kitty.conf watcher directive (removed invalid --type=global
prefix that caused a FileNotFoundError on every kitty startup).
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
watcher.py— a kitty Python watcher that captures terminal scrollback to~/.terminal_history/on every window or pane close, regardless of how the terminal is closed (Ctrl+D, keybind, clicking X, full kitty quit)kitty.confwatcher directive: removes invalid--type=globalprefix that caused aFileNotFoundErroron every kitty startup, meaning the watcher was never loadedREADME.mdHow it works
Two components handle logging:
smart_exit(existing) — intercepts gracefulexitcalls, logs scrollback viakitty @, and setslogged_by_shell=trueon the window to signal the Python watcher to skip itwatcher.py(new) — registerson_close(fires per window on destruction) andon_quit(fires when kitty quits, iterates all windows) hooks; skips windows already logged by the shell or already logged in this sessionManual Verification
journalctl --user _COMM=kittyCtrl+D— verify a newscrollback_*.logappears in~/.terminal_history/exitin a fish shell — verify only one log is created (not duplicated by both fish and watcher)