thefuck: Add alias option (#6909)
Added an alias option supported by bash, zsh, fish, and nushell integration
This commit is contained in:
parent
542078066b
commit
4d2d322317
3 changed files with 13 additions and 7 deletions
|
|
@ -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)"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)"'
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue