From 2af7c78b7bb9cf18406a193eba13ef9f99388f49 Mon Sep 17 00:00:00 2001 From: Alvaro Fresquet <29437693+afresquet@users.noreply.github.com> Date: Mon, 29 Apr 2024 09:53:42 +0200 Subject: [PATCH] thefuck: add nushell integration --- modules/programs/thefuck.nix | 14 ++++++++++++++ .../programs/thefuck/integration-disabled.nix | 3 +++ .../programs/thefuck/integration-enabled.nix | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/modules/programs/thefuck.nix b/modules/programs/thefuck.nix index 2cad4c338..ab56ea016 100644 --- a/modules/programs/thefuck.nix +++ b/modules/programs/thefuck.nix @@ -32,6 +32,14 @@ with lib; Whether to enable Zsh integration. ''; }; + + enableNushellIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Nushell integration. + ''; + }; }; config = let @@ -66,5 +74,11 @@ with lib; }; programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd; + + programs.nushell = mkIf cfg.enableNushellIntegration { + extraConfig = '' + alias fuck = ${cfg.package}/bin/thefuck $"(history | last 1 | get command | get 0)" + ''; + }; }; } diff --git a/tests/modules/programs/thefuck/integration-disabled.nix b/tests/modules/programs/thefuck/integration-disabled.nix index 9a55efac0..456963596 100644 --- a/tests/modules/programs/thefuck/integration-disabled.nix +++ b/tests/modules/programs/thefuck/integration-disabled.nix @@ -6,8 +6,10 @@ thefuck.enableBashIntegration = false; thefuck.enableFishIntegration = false; thefuck.enableZshIntegration = false; + thefuck.enableNushellIntegration = false; bash.enable = true; zsh.enable = true; + nushell.enable = true; }; test.stubs.thefuck = { }; @@ -16,5 +18,6 @@ assertFileNotRegex home-files/.bashrc '@thefuck@/bin/thefuck' assertPathNotExists home-files/.config/fish/functions/fuck.fish assertFileNotRegex home-files/.zshrc '@thefuck@/bin/thefuck' + assertFileNotRegex home-files/.config/nushell/config.nu '@thefuck@/bin/thefuck' ''; } diff --git a/tests/modules/programs/thefuck/integration-enabled.nix b/tests/modules/programs/thefuck/integration-enabled.nix index 79cadaf81..54d6b794e 100644 --- a/tests/modules/programs/thefuck/integration-enabled.nix +++ b/tests/modules/programs/thefuck/integration-enabled.nix @@ -6,6 +6,7 @@ bash.enable = true; fish.enable = true; zsh.enable = true; + nushell.enable = true; }; test.stubs.thefuck = { }; @@ -33,5 +34,10 @@ assertFileContains \ home-files/.zshrc \ 'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"' + + assertFileExists home-files/.config/nushell/config.nu + assertFileContains \ + home-files/.config/nushell/config.nu \ + 'alias fuck = @thefuck@/bin/thefuck $"(history | last 1 | get command | get 0)"' ''; }