refactor(kitty-logging): move watcher to scripts/ and symlink it

Relocate the Kitty scrollback watcher out of the single-purpose kitty/
directory into scripts/kitty-fish-config-watcher.py, and change the
installer to symlink it into the Kitty config directory instead of
copying it.

The symlink always tracks the canonical source, which removes the
version-staleness comparison and the copy-vs-refresh messaging. uninstall
now removes a symlink (including a dangling one) or a legacy copied file.
Existing installs migrate automatically on the next `kitty-logging install`.

Docs (README, docs/fish-config.md, wiki) updated to match.
This commit is contained in:
2026-07-16 02:39:41 -04:00
parent 8c869cc1b9
commit 29b69c7b03
5 changed files with 30 additions and 34 deletions
+2 -2
View File
@@ -104,8 +104,8 @@ one-time-per-session reminder. Manage it with:
| Command | Action | | Command | Action |
|---|---| |---|---|
| `kitty-logging install` | Copy the watcher into your Kitty config and wire it into `kitty.conf` | | `kitty-logging install` | Symlink the watcher into your Kitty config and wire it into `kitty.conf` |
| `kitty-logging uninstall` | Remove the managed block and the watcher file | | `kitty-logging uninstall` | Remove the managed block and the watcher symlink |
| `kitty-logging status` | Show whether it's wired, the watcher version, and C5 state | | `kitty-logging status` | Show whether it's wired, the watcher version, and C5 state |
| `kitty-logging dismiss` | Stop the per-session reminder without installing | | `kitty-logging dismiss` | Stop the per-session reminder without installing |
+9 -8
View File
@@ -1568,13 +1568,14 @@ Add -i (interactive confirmation) to destructive commands:
Synopsis: kitty-logging [install|uninstall|status|dismiss] [-h] Synopsis: kitty-logging [install|uninstall|status|dismiss] [-h]
Manages the Kitty scrollback watcher that powers C5 logging. Ships a Manages the Kitty scrollback watcher that powers C5 logging. Ships a
canonical, version-marked watcher and installs it into the Kitty config canonical watcher and symlinks it into the Kitty config directory (so it
directory, wiring it into kitty.conf through a sentinel-marked managed always tracks the source), wiring it into kitty.conf through a
block. Commenting out any conflicting watcher line avoids double-capture. sentinel-marked managed block. Commenting out any conflicting watcher line
avoids double-capture.
Commands: Commands:
install Copy/refresh the watcher and add the managed block install Symlink the watcher and add the managed block
uninstall Remove the managed block and the watcher file uninstall Remove the managed block and the watcher symlink
status Show wiring, installed watcher version, and C5 state status Show wiring, installed watcher version, and C5 state
dismiss Stop the per-session setup reminder dismiss Stop the per-session setup reminder
@@ -1985,9 +1986,9 @@ snapshot point from the shell is a clean exit. To guarantee a zellij pane is
logged, end the session with `exit` or Ctrl-D rather than zellij's close-pane logged, end the session with `exit` or Ctrl-D rather than zellij's close-pane
or quit actions. or quit actions.
The Kitty watcher is managed by the kitty-logging command: it installs a The Kitty watcher is managed by the kitty-logging command: it symlinks the
version-marked watcher (fish-config-watcher.py) into the Kitty config directory watcher (fish-config-watcher.py) into the Kitty config directory and wires it
and wires it into kitty.conf via a managed block. Inside Kitty, a non-blocking into kitty.conf via a managed block. Inside Kitty, a non-blocking
per-session reminder points first-time users at `kitty-logging install` until per-session reminder points first-time users at `kitty-logging install` until
they install or run `kitty-logging dismiss`. Install affects new Kitty windows they install or run `kitty-logging dismiss`. Install affects new Kitty windows
only; runtime disable is still handled by the .logging_disabled sentinel. only; runtime disable is still handled by the .logging_disabled sentinel.
+3 -3
View File
@@ -319,9 +319,9 @@ snapshot point from the shell is a clean exit. To guarantee a zellij pane is
logged, end the session with `exit` or Ctrl-D rather than zellij's close-pane logged, end the session with `exit` or Ctrl-D rather than zellij's close-pane
or quit actions. or quit actions.
The Kitty watcher is managed by the kitty-logging command: it installs a The Kitty watcher is managed by the kitty-logging command: it symlinks the
version-marked watcher (fish-config-watcher.py) into the Kitty config directory watcher (fish-config-watcher.py) into the Kitty config directory and wires it
and wires it into kitty.conf via a managed block. Inside Kitty, a non-blocking into kitty.conf via a managed block. Inside Kitty, a non-blocking
per-session reminder points first-time users at `kitty-logging install` until per-session reminder points first-time users at `kitty-logging install` until
they install or run `kitty-logging dismiss`. Install affects new Kitty windows they install or run `kitty-logging dismiss`. Install affects new Kitty windows
only; runtime disable is still handled by the .logging_disabled sentinel. only; runtime disable is still handled by the .logging_disabled sentinel.
+13 -18
View File
@@ -69,7 +69,7 @@ function kitty-logging --description 'Install/manage the fish-config Kitty scrol
set -l kitty_dir (__kitty_logging_dir) set -l kitty_dir (__kitty_logging_dir)
set -l conf "$kitty_dir/kitty.conf" set -l conf "$kitty_dir/kitty.conf"
set -l src "$__fish_config_dir/kitty/fish-config-watcher.py" set -l src "$__fish_config_dir/scripts/kitty-fish-config-watcher.py"
set -l dst "$kitty_dir/fish-config-watcher.py" set -l dst "$kitty_dir/fish-config-watcher.py"
set -l blk_begin "# >>> fish-config logging (managed — do not edit) >>>" set -l blk_begin "# >>> fish-config logging (managed — do not edit) >>>"
set -l blk_end "# <<< fish-config logging (managed) <<<" set -l blk_end "# <<< fish-config logging (managed) <<<"
@@ -107,25 +107,19 @@ function kitty-logging --description 'Install/manage the fish-config Kitty scrol
return 1 return 1
end end
# Copy/refresh the watcher when missing or stale. A failed copy must # Symlink the watcher into the kitty config dir so it always tracks
# abort: otherwise we would wire a managed block pointing at a watcher # the canonical source (no copy, no staleness). ln -sfn replaces a
# file that does not exist and report success. # stale link or a legacy copied file. A failed link must abort:
set -l copied 0 # otherwise we would wire a managed block pointing at a missing
if not test -f $dst; or test (__kitty_logging_version $src) -gt (__kitty_logging_version $dst) # watcher and report success.
if not command cp $src $dst if not command ln -sfn $src $dst
echo "$c_err""kitty-logging: failed to copy watcher to $dst$c_reset" >&2 echo "$c_err""kitty-logging: failed to symlink watcher to $dst$c_reset" >&2
return 1 return 1
end
set copied 1
end end
# Already wired: idempotent no-op (watcher may still have refreshed). # Already wired: idempotent no-op.
if test -f $conf; and command grep -qF -- "$blk_begin" $conf if test -f $conf; and command grep -qF -- "$blk_begin" $conf
if test $copied -eq 1 echo "$c_ok""→ Already installed.$c_reset"
echo "$c_ok""→ Watcher updated.$c_reset Already wired in $conf."
else
echo "$c_ok""→ Already installed.$c_reset"
end
return 0 return 0
end end
@@ -158,7 +152,8 @@ function kitty-logging --description 'Install/manage the fish-config Kitty scrol
else else
echo "$c_dim""→ No managed block found in $conf$c_reset" echo "$c_dim""→ No managed block found in $conf$c_reset"
end end
if test -f $dst # -L catches the symlink (even if dangling); -f catches a legacy copy.
if test -L $dst; or test -f $dst
command rm -f $dst command rm -f $dst
echo "$c_ok""→ Removed $dst$c_reset" echo "$c_ok""→ Removed $dst$c_reset"
end end
@@ -3,9 +3,9 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# fish-config-watcher-version: 1 # fish-config-watcher-version: 1
# #
# Managed by fish-config `kitty-logging`. Do not edit in place — edit the # Managed by fish-config `kitty-logging`, which symlinks this file into the
# canonical copy at ~/.config/fish/kitty/fish-config-watcher.py and re-run # Kitty config directory. The canonical source lives at
# `kitty-logging install`. # ~/.config/fish/scripts/kitty-fish-config-watcher.py.
import datetime import datetime
import os import os