mirror of
https://github.com/nix-community/home-manager
synced 2024-11-19 17:49: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, ... }:
|
||||
|
||||
with lib;
|
||||
let cfg = config.programs.thefuck;
|
||||
in {
|
||||
|
||||
{
|
||||
meta.maintainers = [ hm.maintainers.ilaumjd ];
|
||||
|
||||
options.programs.thefuck = {
|
||||
|
@ -10,6 +11,8 @@ in {
|
|||
|
||||
package = mkPackageOption pkgs "thefuck" { };
|
||||
|
||||
enableInstantMode = mkEnableOption "thefuck's experimental instant mode";
|
||||
|
||||
enableBashIntegration = mkOption {
|
||||
default = true;
|
||||
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 ];
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
eval "$(${cfg.package}/bin/thefuck --alias)"
|
||||
'';
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration shEvalCmd;
|
||||
|
||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
eval "$(${cfg.package}/bin/thefuck --alias)"
|
||||
'';
|
||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shEvalCmd;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
thefuck-integration-enabled = ./integration-enabled.nix;
|
||||
thefuck-integration-enabled-instant = ./integration-enabled-instant.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
|
||||
assertFileContains \
|
||||
home-files/.bashrc \
|
||||
'eval "$(@thefuck@/bin/thefuck --alias)"'
|
||||
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
||||
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'eval "$(@thefuck@/bin/thefuck --alias)"'
|
||||
'eval "$(@thefuck@/bin/thefuck '"'"'--alias'"'"')"'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue