Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kitty allow not setting shell_integration=no_rc #5809

Open
MithicSpirit opened this issue Sep 6, 2024 · 2 comments · May be fixed by #5960
Open

Kitty allow not setting shell_integration=no_rc #5809

MithicSpirit opened this issue Sep 6, 2024 · 2 comments · May be fixed by #5960
Assignees

Comments

@MithicSpirit
Copy link
Contributor

MithicSpirit commented Sep 6, 2024

Description

I would appreciate it if there was a way to disable setting shell_integration = no-rc in kitty. This is because I don't have home-manager managing my shell config, and so I want to use kitty's built-in shell integration method, but if no-rc is always enabled this is impossible. It's possible to work around this by setting settings.shell_integration since that makes it appear twice in the config, and it seems like the latter entry overrides the former, but this feels janky.

The solution I've come up with is that manually setting shellIntegration.mode = ""; should make that not show up at all in the config. I believe this (untested) patch should make it behave as such. I can do some testing and submit this as a PR if desired.

diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix
index 48ec13da..ffc66c5b 100644
--- a/modules/programs/kitty.nix
+++ b/modules/programs/kitty.nix
@@ -144,20 +144,20 @@ in {
     shellIntegration = {
       mode = mkOption {
         type = types.str;
         default = "no-rc";
         example = "no-cursor";
         apply = (o:
-          let
+          optionalString o (let
             modes = splitString " " o;
             filtered = filter (m: m != "no-rc") modes;
-          in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]));
+          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
-          `no-rc` is always implied. See
+          `no-rc` is always implied if nonempty. See
           <https://sw.kovidgoyal.net/kitty/shell-integration>
           for more details.
         '';
       };
 
       enableBashIntegration = mkEnableOption "Kitty Bash integration"
@@ -200,16 +200,16 @@ in {
                   "${pkgs.kitty-themes}/share/kitty-themes/themes.json"));
             in throwIf (length matching == 0)
             "kitty-themes does not contain a theme named ${cfg.theme}"
             (head matching).file
           }
         '')
-        ''
+        (optionalString cfg.shellIntegration.mode ''
           # Shell integration is sourced and configured manually
           shell_integration ${cfg.shellIntegration.mode}
-        ''
+        '')
         (toKittyConfig cfg.settings)
         (toKittyKeybindings cfg.keybindings)
         (toKittyEnv cfg.environment)
         cfg.extraConfig
       ]);
     } // optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
@teto
Copy link
Collaborator

teto commented Oct 7, 2024

I would rather compare against null then "". PR welcome

@MithicSpirit
Copy link
Contributor Author

MithicSpirit commented Oct 7, 2024

Yeah, that's a good idea. I've been pretty busy, but I'll submit the PR when I have time. Likely this weekend.

@MithicSpirit MithicSpirit linked a pull request Oct 13, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants