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.
This commit is contained in:
Anton Volnuhin 2026-08-06 05:04:05 +03:00
parent 9e2667f8fe
commit ccf4a18c86
2 changed files with 36 additions and 34 deletions

View File

@ -1,37 +1,29 @@
# 1984 theme by Bertie Blackman, https://github.com/covertbert/iterm2-1984/
foreground #ffffff
background #0d0f31
selection_foreground #000000
selection_background #00d5eb
color0 #000000
color1 #ff16b0
color2 #b3f361
color3 #ffea16
color4 #46bdff
color5 #f806fa
color6 #59e1e3
color7 #feffff
color8 #000000
color9 #ff16b0
color10 #b3f361
color11 #ffea16
color12 #46bdff
color13 #f806fa
color14 #6be4e6
color15 #feffff
# URL styles
url_color #f806fa
url_style single
# Cursor styles
cursor #59e1e3
background #090200
foreground #a4a1a1
cursor #a4a1a1
selection_background #494542
color0 #090200
color8 #5b5754
color1 #da2c20
color9 #e8bacf
color2 #00a152
color10 #3a3332
color3 #fcec02
color11 #494542
color4 #00a0e4
color12 #7f7c7b
color5 #a06994
color13 #d6d4d3
color6 #b5e4f4
color14 #ccab53
color7 #a4a1a1
color15 #f7f7f7
selection_foreground #090200
# START_AUTOGENERATED_TAB_STYLE
# Feel free to update these colors manually and remove these comments.
active_tab_foreground #eeeeee
active_tab_background #00d5eb
inactive_tab_foreground #ffffff
inactive_tab_background #0a0c27
active_tab_background #494542
inactive_tab_foreground #a4a1a1
inactive_tab_background #070200
# END_AUTOGENERATED_TAB_STYLE

View File

@ -4,6 +4,17 @@ function kitten --description 'Run kitten and restore Kitty theme overrides'
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
@ -13,8 +24,7 @@ function kitten --description 'Run kitten and restore Kitty theme overrides'
# -- `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 (count $argv) -gt 0
and test "$argv[1]" = themes
and test $is_themes = true
"$HOME/.config/kitty/apply-theme-mode.sh" "$config_dir"
or return $status