mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 01:59:45 +01:00
thefuck: add instant mode option
Also do a slight code cleanup.
This commit is contained in:
parent
b3acf1dc78
commit
3e1f8df4f0
4 changed files with 48 additions and 11 deletions
|
@ -1,7 +1,8 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let cfg = config.programs.thefuck;
|
|
||||||
in {
|
{
|
||||||
meta.maintainers = [ hm.maintainers.ilaumjd ];
|
meta.maintainers = [ hm.maintainers.ilaumjd ];
|
||||||
|
|
||||||
options.programs.thefuck = {
|
options.programs.thefuck = {
|
||||||
|
@ -10,6 +11,8 @@ in {
|
||||||
|
|
||||||
package = mkPackageOption pkgs "thefuck" { };
|
package = mkPackageOption pkgs "thefuck" { };
|
||||||
|
|
||||||
|
enableInstantMode = mkEnableOption "thefuck's experimental instant mode";
|
||||||
|
|
||||||
enableBashIntegration = mkOption {
|
enableBashIntegration = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -27,15 +30,22 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = let
|
||||||
|
cfg = config.programs.thefuck;
|
||||||
|
|
||||||
|
cliArgs = cli.toGNUCommandLineShell { } {
|
||||||
|
alias = true;
|
||||||
|
enable-experimental-instant-mode = cfg.enableInstantMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
shEvalCmd = ''
|
||||||
|
eval "$(${cfg.package}/bin/thefuck ${cliArgs})"
|
||||||
|
'';
|
||||||
|
in mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
|
||||||
eval "$(${cfg.package}/bin/thefuck --alias)"
|
|
||||||
'';
|
|
||||||
|
|
||||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
|
||||||
eval "$(${cfg.package}/bin/thefuck --alias)"
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
thefuck-integration-enabled = ./integration-enabled.nix;
|
thefuck-integration-enabled = ./integration-enabled.nix;
|
||||||
|
thefuck-integration-enabled-instant = ./integration-enabled-instant.nix;
|
||||||
thefuck-integration-disabled = ./integration-disabled.nix;
|
thefuck-integration-disabled = ./integration-disabled.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs = {
|
||||||
|
thefuck = {
|
||||||
|
enable = true;
|
||||||
|
enableInstantMode = true;
|
||||||
|
};
|
||||||
|
bash.enable = true;
|
||||||
|
zsh.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.thefuck = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.bashrc
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.bashrc \
|
||||||
|
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"' '"'"'--enable-experimental-instant-mode'"'"')"'
|
||||||
|
|
||||||
|
assertFileExists home-files/.zshrc
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.zshrc \
|
||||||
|
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"' '"'"'--enable-experimental-instant-mode'"'"')"'
|
||||||
|
'';
|
||||||
|
}
|
|
@ -13,11 +13,11 @@
|
||||||
assertFileExists home-files/.bashrc
|
assertFileExists home-files/.bashrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.bashrc \
|
home-files/.bashrc \
|
||||||
'eval "$(@thefuck@/bin/thefuck --alias)"'
|
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
||||||
|
|
||||||
assertFileExists home-files/.zshrc
|
assertFileExists home-files/.zshrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.zshrc \
|
home-files/.zshrc \
|
||||||
'eval "$(@thefuck@/bin/thefuck --alias)"'
|
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue