From 2752c42035aa89c21de5396648a691c375353100 Mon Sep 17 00:00:00 2001 From: musjj <72612857+musjj@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:10:32 +0700 Subject: [PATCH] kitty: always export `KITTY_SHELL_INTEGRATION` This ensures that `KITTY_SHELL_INTEGRATION` is manually set to the user's `shellIntegration.mode`. This is necessary because sometimes the variable is not set in subshells or splits. `shellIntegration.mode` is also now ensured to always contain `no-rc`. --- modules/programs/kitty.nix | 16 ++++++++++++---- .../kitty/example-settings-expected.conf | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index e010ba09f..48ec13da4 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -29,17 +29,20 @@ let shellIntegrationInit = { bash = '' if test -n "$KITTY_INSTALLATION_DIR"; then + export KITTY_SHELL_INTEGRATION="${cfg.shellIntegration.mode}" source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash" fi ''; fish = '' if set -q KITTY_INSTALLATION_DIR + set --global KITTY_SHELL_INTEGRATION "${cfg.shellIntegration.mode}" source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish" set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d" end ''; zsh = '' if test -n "$KITTY_INSTALLATION_DIR"; then + export KITTY_SHELL_INTEGRATION="${cfg.shellIntegration.mode}" autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration kitty-integration unfunction kitty-integration @@ -48,9 +51,9 @@ let }; shellIntegrationDefaultOpt = { - default = cfg.shellIntegration.mode != "disabled"; + default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode)); defaultText = literalExpression '' - config.programs.kitty.shellIntegration.mode != "disabled" + !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode)) ''; }; in { @@ -141,8 +144,13 @@ in { shellIntegration = { mode = mkOption { type = types.str; - default = "enabled"; + default = "no-rc"; example = "no-cursor"; + apply = (o: + let + modes = splitString " " o; + filtered = filter (m: m != "no-rc") modes; + in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ])); description = '' Set the mode of the shell integration. This accepts the same options as the `shell_integration` option of Kitty. Note that @@ -197,7 +205,7 @@ in { '') '' # Shell integration is sourced and configured manually - shell_integration no-rc ${cfg.shellIntegration.mode} + shell_integration ${cfg.shellIntegration.mode} '' (toKittyConfig cfg.settings) (toKittyKeybindings cfg.keybindings) diff --git a/tests/modules/programs/kitty/example-settings-expected.conf b/tests/modules/programs/kitty/example-settings-expected.conf index 41a209eae..aca1b0c18 100644 --- a/tests/modules/programs/kitty/example-settings-expected.conf +++ b/tests/modules/programs/kitty/example-settings-expected.conf @@ -5,7 +5,7 @@ font_size 8 # Shell integration is sourced and configured manually -shell_integration no-rc enabled +shell_integration no-rc enable_audio_bell no scrollback_lines 10000