From 4d2d32231797bfa7213ae5e8ac89d25f8caaae82 Mon Sep 17 00:00:00 2001 From: Coolio Date: Fri, 25 Apr 2025 19:39:49 -0500 Subject: [PATCH] thefuck: Add alias option (#6909) Added an alias option supported by bash, zsh, fish, and nushell integration --- modules/programs/thefuck.nix | 12 +++++++++--- .../programs/thefuck/integration-enabled-instant.nix | 4 ++-- .../modules/programs/thefuck/integration-enabled.nix | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/programs/thefuck.nix b/modules/programs/thefuck.nix index ac5eeff4..42e5fe92 100644 --- a/modules/programs/thefuck.nix +++ b/modules/programs/thefuck.nix @@ -24,6 +24,12 @@ in enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + + alias = lib.mkOption { + type = lib.types.str; + default = "fuck"; + description = "Alias used to invoke `thefuck`."; + }; }; config = @@ -31,7 +37,7 @@ in cfg = config.programs.thefuck; cliArgs = lib.cli.toGNUCommandLineShell { } { - alias = true; + alias = cfg.alias; enable-experimental-instant-mode = cfg.enableInstantMode; }; @@ -49,7 +55,7 @@ in description = "Correct your previous console command"; body = '' set -l fucked_up_command $history[1] - env TF_SHELL=fish TF_ALIAS=fuck PYTHONIOENCODING=utf-8 ${cfg.package}/bin/thefuck $fucked_up_command THEFUCK_ARGUMENT_PLACEHOLDER $argv | read -l unfucked_command + env TF_SHELL=fish TF_ALIAS=${cfg.alias} PYTHONIOENCODING=utf-8 ${cfg.package}/bin/thefuck $fucked_up_command THEFUCK_ARGUMENT_PLACEHOLDER $argv | read -l unfucked_command if [ "$unfucked_command" != "" ] eval $unfucked_command builtin history delete --exact --case-sensitive -- $fucked_up_command @@ -63,7 +69,7 @@ in programs.nushell = mkIf cfg.enableNushellIntegration { extraConfig = '' - alias fuck = ${cfg.package}/bin/thefuck $"(history | last 1 | get command | get 0)" + alias ${cfg.alias} = ${cfg.package}/bin/thefuck $"(history | last 1 | get command | get 0)" ''; }; }; diff --git a/tests/modules/programs/thefuck/integration-enabled-instant.nix b/tests/modules/programs/thefuck/integration-enabled-instant.nix index 8d007e68..adc22b22 100644 --- a/tests/modules/programs/thefuck/integration-enabled-instant.nix +++ b/tests/modules/programs/thefuck/integration-enabled-instant.nix @@ -12,11 +12,11 @@ assertFileExists home-files/.bashrc assertFileContains \ home-files/.bashrc \ - 'eval "$(@thefuck@/bin/thefuck --alias --enable-experimental-instant-mode)"' + 'eval "$(@thefuck@/bin/thefuck --alias fuck --enable-experimental-instant-mode)"' assertFileExists home-files/.zshrc assertFileContains \ home-files/.zshrc \ - 'eval "$(@thefuck@/bin/thefuck --alias --enable-experimental-instant-mode)"' + 'eval "$(@thefuck@/bin/thefuck --alias fuck --enable-experimental-instant-mode)"' ''; } diff --git a/tests/modules/programs/thefuck/integration-enabled.nix b/tests/modules/programs/thefuck/integration-enabled.nix index dae5cebe..7a9e487b 100644 --- a/tests/modules/programs/thefuck/integration-enabled.nix +++ b/tests/modules/programs/thefuck/integration-enabled.nix @@ -11,7 +11,7 @@ assertFileExists home-files/.bashrc assertFileContains \ home-files/.bashrc \ - 'eval "$(@thefuck@/bin/thefuck --alias)"' + 'eval "$(@thefuck@/bin/thefuck --alias fuck)"' assertFileExists home-files/.config/fish/functions/fuck.fish assertFileContains \ @@ -29,7 +29,7 @@ assertFileExists home-files/.zshrc assertFileContains \ home-files/.zshrc \ - 'eval "$(@thefuck@/bin/thefuck --alias)"' + 'eval "$(@thefuck@/bin/thefuck --alias fuck)"' assertFileExists home-files/.config/nushell/config.nu assertFileContains \