mirror of
https://github.com/nix-community/home-manager
synced 2024-12-24 18:59:47 +01:00
kitty: add shellIntegration (#3759)
Kitty provides integrations for bash, fish and zsh. The new programs.kitty.shellIntegration options allow the configuration of these integrations. See <https://sw.kovidgoyal.net/kitty/shell-integration> for more details. Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
cc9f65d104
commit
a835096fd2
2 changed files with 61 additions and 0 deletions
|
@ -26,6 +26,33 @@ let
|
||||||
toKittyEnv =
|
toKittyEnv =
|
||||||
generators.toKeyValue { mkKeyValue = name: value: "env ${name}=${value}"; };
|
generators.toKeyValue { mkKeyValue = name: value: "env ${name}=${value}"; };
|
||||||
|
|
||||||
|
shellIntegrationInit = {
|
||||||
|
bash = ''
|
||||||
|
if test -n "$KITTY_INSTALLATION_DIR"; then
|
||||||
|
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
fish = ''
|
||||||
|
if set -q KITTY_INSTALLATION_DIR
|
||||||
|
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
|
||||||
|
autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration
|
||||||
|
kitty-integration
|
||||||
|
unfunction kitty-integration
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
shellIntegrationDefaultOpt = {
|
||||||
|
default = cfg.shellIntegration.mode != "disabled";
|
||||||
|
defaultText = literalExpression ''
|
||||||
|
config.programs.kitty.shellIntegration.mode != "disabled"
|
||||||
|
'';
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.programs.kitty = {
|
options.programs.kitty = {
|
||||||
enable = mkEnableOption "Kitty terminal emulator";
|
enable = mkEnableOption "Kitty terminal emulator";
|
||||||
|
@ -111,6 +138,27 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shellIntegration = {
|
||||||
|
mode = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "enabled";
|
||||||
|
description = ''
|
||||||
|
Set the mode of the shell integration. This accepts the same options
|
||||||
|
as the shell_integration option of Kitty. Note that no-rc is always
|
||||||
|
implied. See
|
||||||
|
<link xlink:href="https://sw.kovidgoyal.net/kitty/shell-integration"/>
|
||||||
|
for more details.
|
||||||
|
'';
|
||||||
|
example = "no-cursor";
|
||||||
|
};
|
||||||
|
enableBashIntegration = mkEnableOption "Kitty bash integration"
|
||||||
|
// shellIntegrationDefaultOpt;
|
||||||
|
enableFishIntegration = mkEnableOption "Kitty fish integration"
|
||||||
|
// shellIntegrationDefaultOpt;
|
||||||
|
enableZshIntegration = mkEnableOption "Kitty zsh integration"
|
||||||
|
// shellIntegrationDefaultOpt;
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -140,6 +188,10 @@ in {
|
||||||
"${pkgs.kitty-themes}/share/kitty-themes/themes.json")))).file
|
"${pkgs.kitty-themes}/share/kitty-themes/themes.json")))).file
|
||||||
}
|
}
|
||||||
'')
|
'')
|
||||||
|
''
|
||||||
|
# Shell integration is sourced and configured manually
|
||||||
|
shell_integration no-rc ${cfg.shellIntegration.mode}
|
||||||
|
''
|
||||||
(toKittyConfig cfg.settings)
|
(toKittyConfig cfg.settings)
|
||||||
(toKittyKeybindings cfg.keybindings)
|
(toKittyKeybindings cfg.keybindings)
|
||||||
(toKittyEnv cfg.environment)
|
(toKittyEnv cfg.environment)
|
||||||
|
@ -155,5 +207,11 @@ in {
|
||||||
(cfg.darwinLaunchOptions != null && pkgs.stdenv.hostPlatform.isDarwin) {
|
(cfg.darwinLaunchOptions != null && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||||
text = concatStringsSep " " cfg.darwinLaunchOptions;
|
text = concatStringsSep " " cfg.darwinLaunchOptions;
|
||||||
};
|
};
|
||||||
|
programs.bash.initExtra =
|
||||||
|
mkIf cfg.shellIntegration.enableBashIntegration shellIntegrationInit.bash;
|
||||||
|
programs.fish.interactiveShellInit =
|
||||||
|
mkIf cfg.shellIntegration.enableFishIntegration shellIntegrationInit.fish;
|
||||||
|
programs.zsh.initExtra =
|
||||||
|
mkIf cfg.shellIntegration.enableZshIntegration shellIntegrationInit.zsh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ font_family DejaVu Sans
|
||||||
font_size 8
|
font_size 8
|
||||||
|
|
||||||
|
|
||||||
|
# Shell integration is sourced and configured manually
|
||||||
|
shell_integration no-rc enabled
|
||||||
|
|
||||||
enable_audio_bell no
|
enable_audio_bell no
|
||||||
scrollback_lines 10000
|
scrollback_lines 10000
|
||||||
update_check_interval 0
|
update_check_interval 0
|
||||||
|
|
Loading…
Reference in a new issue