1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-10 21:29:48 +01:00

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`.
This commit is contained in:
musjj 2024-02-05 06:10:32 +07:00 committed by Mikilio
parent 7d4dc024de
commit 2752c42035
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 13 additions and 5 deletions

View file

@ -29,17 +29,20 @@ let
shellIntegrationInit = { shellIntegrationInit = {
bash = '' bash = ''
if test -n "$KITTY_INSTALLATION_DIR"; then if test -n "$KITTY_INSTALLATION_DIR"; then
export KITTY_SHELL_INTEGRATION="${cfg.shellIntegration.mode}"
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash" source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
fi fi
''; '';
fish = '' fish = ''
if set -q KITTY_INSTALLATION_DIR 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" 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" set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end end
''; '';
zsh = '' zsh = ''
if test -n "$KITTY_INSTALLATION_DIR"; then if test -n "$KITTY_INSTALLATION_DIR"; then
export KITTY_SHELL_INTEGRATION="${cfg.shellIntegration.mode}"
autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration
kitty-integration kitty-integration
unfunction kitty-integration unfunction kitty-integration
@ -48,9 +51,9 @@ let
}; };
shellIntegrationDefaultOpt = { shellIntegrationDefaultOpt = {
default = cfg.shellIntegration.mode != "disabled"; default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode));
defaultText = literalExpression '' defaultText = literalExpression ''
config.programs.kitty.shellIntegration.mode != "disabled" !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode))
''; '';
}; };
in { in {
@ -141,8 +144,13 @@ in {
shellIntegration = { shellIntegration = {
mode = mkOption { mode = mkOption {
type = types.str; type = types.str;
default = "enabled"; default = "no-rc";
example = "no-cursor"; example = "no-cursor";
apply = (o:
let
modes = splitString " " o;
filtered = filter (m: m != "no-rc") modes;
in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]));
description = '' description = ''
Set the mode of the shell integration. This accepts the same options Set the mode of the shell integration. This accepts the same options
as the `shell_integration` option of Kitty. Note that as the `shell_integration` option of Kitty. Note that
@ -197,7 +205,7 @@ in {
'') '')
'' ''
# Shell integration is sourced and configured manually # Shell integration is sourced and configured manually
shell_integration no-rc ${cfg.shellIntegration.mode} shell_integration ${cfg.shellIntegration.mode}
'' ''
(toKittyConfig cfg.settings) (toKittyConfig cfg.settings)
(toKittyKeybindings cfg.keybindings) (toKittyKeybindings cfg.keybindings)

View file

@ -5,7 +5,7 @@ font_size 8
# Shell integration is sourced and configured manually # Shell integration is sourced and configured manually
shell_integration no-rc enabled shell_integration no-rc
enable_audio_bell no enable_audio_bell no
scrollback_lines 10000 scrollback_lines 10000