dotfiles/private_dot_config/private_fish/functions/private_kitten.fish
Anton Volnuhin ccf4a18c86 kitty: match any prefix of the themes kitten, not just "themes"
`kitten theme` runs the themes kitten -- kitty accepts unambiguous prefixes
-- but the shim tested `$argv[1] = themes` exactly, so that spelling skipped
the capture and re-apply entirely. Before the theme-mode work that was
harmless, since nothing rewrote the automatic theme files; now the next
regeneration reverts whatever was just chosen, which is why picking a theme
stopped sticking.

Accept any prefix of "themes" at least two characters long. Verified that
themes/theme/them/th all trigger and icat still does not.
2026-08-06 05:04:05 +03:00

39 lines
1.4 KiB
Fish

function kitten --description 'Run kitten and restore Kitty theme overrides'
set -l config_dir "$HOME/.config/kitty"
if set -q KITTY_CONFIG_DIRECTORY
set config_dir "$KITTY_CONFIG_DIRECTORY"
end
# kitty accepts any unambiguous prefix of a kitten name, so `kitten theme`
# runs the themes kitten just as `kitten themes` does. Match the same way:
# an exact `= themes` test silently skips the re-apply below and the next
# regeneration then reverts the theme that was just chosen.
set -l is_themes false
if test (count $argv) -gt 0
and test (string length -- "$argv[1]") -ge 2
and string match -q -- "$argv[1]*" themes
set is_themes true
end
command kitten $argv
set -l kitten_status $status
# Re-apply the pinned mode over whatever the themes kitten just wrote, and
# reload so the change shows immediately. apply-theme-mode.sh does the
# capturing itself, by checksum, so a theme saved through some other route
# -- `kitty +kitten themes`, a keybinding, another shell -- is picked up on
# its next run rather than being lost.
if test $kitten_status -eq 0
and test $is_themes = true
"$HOME/.config/kitty/apply-theme-mode.sh" "$config_dir"
or return $status
if set -q KITTY_WINDOW_ID
command kitty @ load-config
or return $status
end
end
return $kitten_status
end