mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
thefuck: add fish integration (#4535)
Co-authored-by: Sumner Evans <me@sumnerevans.com>
This commit is contained in:
parent
831b4fa317
commit
8765d4e38a
3 changed files with 35 additions and 0 deletions
|
@ -21,6 +21,10 @@ with lib;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableFishIntegration = mkEnableOption "Fish integration" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
enableZshIntegration = mkOption {
|
enableZshIntegration = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -46,6 +50,21 @@ with lib;
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
|
||||||
|
|
||||||
|
programs.fish.functions = mkIf cfg.enableFishIntegration {
|
||||||
|
fuck = {
|
||||||
|
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
|
||||||
|
if [ "$unfucked_command" != "" ]
|
||||||
|
eval $unfucked_command
|
||||||
|
builtin history delete --exact --case-sensitive -- $fucked_up_command
|
||||||
|
builtin history merge
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
programs = {
|
programs = {
|
||||||
thefuck.enable = true;
|
thefuck.enable = true;
|
||||||
thefuck.enableBashIntegration = false;
|
thefuck.enableBashIntegration = false;
|
||||||
|
thefuck.enableFishIntegration = false;
|
||||||
thefuck.enableZshIntegration = false;
|
thefuck.enableZshIntegration = false;
|
||||||
bash.enable = true;
|
bash.enable = true;
|
||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileNotRegex home-files/.bashrc '@thefuck@/bin/thefuck'
|
assertFileNotRegex home-files/.bashrc '@thefuck@/bin/thefuck'
|
||||||
|
assertFileNotExists home-files/.config/fish/functions/fuck.fish
|
||||||
assertFileNotRegex home-files/.zshrc '@thefuck@/bin/thefuck'
|
assertFileNotRegex home-files/.zshrc '@thefuck@/bin/thefuck'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
programs = {
|
programs = {
|
||||||
thefuck.enable = true;
|
thefuck.enable = true;
|
||||||
bash.enable = true;
|
bash.enable = true;
|
||||||
|
fish.enable = true;
|
||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +16,19 @@
|
||||||
home-files/.bashrc \
|
home-files/.bashrc \
|
||||||
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/fish/functions/fuck.fish
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/fish/functions/fuck.fish \
|
||||||
|
'function fuck --description="Correct your previous console command"
|
||||||
|
set -l fucked_up_command $history[1]
|
||||||
|
env TF_SHELL=fish TF_ALIAS=fuck PYTHONIOENCODING=utf-8 @thefuck@/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
|
||||||
|
builtin history merge
|
||||||
|
end
|
||||||
|
end'
|
||||||
|
|
||||||
assertFileExists home-files/.zshrc
|
assertFileExists home-files/.zshrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.zshrc \
|
home-files/.zshrc \
|
||||||
|
|
Loading…
Reference in a new issue