mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
atuin: add disable key options (#3754)
Co-authored-by: Janik H <janik@aq0.de>
This commit is contained in:
parent
cae54dc45c
commit
215af6252d
6 changed files with 57 additions and 7 deletions
|
@ -50,6 +50,15 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
flags = mkOption {
|
||||||
|
default = [ ];
|
||||||
|
type = types.listOf types.str;
|
||||||
|
example = [ "--disable-up-arrow" "--disable-ctrl-r" ];
|
||||||
|
description = ''
|
||||||
|
Flags to append to the shell hook.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = with types;
|
type = with types;
|
||||||
let
|
let
|
||||||
|
@ -78,7 +87,8 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = let flagsStr = escapeShellArgs cfg.flags;
|
||||||
|
in mkIf cfg.enable {
|
||||||
|
|
||||||
# Always add the configured `atuin` package.
|
# Always add the configured `atuin` package.
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
@ -91,18 +101,18 @@ in {
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||||
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
|
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
|
||||||
source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh"
|
source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh"
|
||||||
eval "$(${cfg.package}/bin/atuin init bash)"
|
eval "$(${cfg.package}/bin/atuin init bash ${flagsStr})"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||||
if [[ $options[zle] = on ]]; then
|
if [[ $options[zle] = on ]]; then
|
||||||
eval "$(${cfg.package}/bin/atuin init zsh)"
|
eval "$(${cfg.package}/bin/atuin init zsh ${flagsStr})"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||||
${cfg.package}/bin/atuin init fish | source
|
${cfg.package}/bin/atuin init fish ${flagsStr} | source
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@
|
||||||
assertFileExists home-files/.bashrc
|
assertFileExists home-files/.bashrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.bashrc \
|
home-files/.bashrc \
|
||||||
'eval "$(@atuin@/bin/atuin init bash)"'
|
'eval "$(@atuin@/bin/atuin init bash )"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,5 @@
|
||||||
atuin-fish = ./fish.nix;
|
atuin-fish = ./fish.nix;
|
||||||
atuin-no-shell = ./no-shell.nix;
|
atuin-no-shell = ./no-shell.nix;
|
||||||
atuin-zsh = ./zsh.nix;
|
atuin-zsh = ./zsh.nix;
|
||||||
|
atuin-set-flags = ./set-flags.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
assertFileExists home-files/.config/fish/config.fish
|
assertFileExists home-files/.config/fish/config.fish
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.config/fish/config.fish \
|
home-files/.config/fish/config.fish \
|
||||||
'atuin init fish | source'
|
'@atuin@/bin/atuin init fish | source'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
39
tests/modules/programs/atuin/set-flags.nix
Normal file
39
tests/modules/programs/atuin/set-flags.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs = {
|
||||||
|
atuin.enable = true;
|
||||||
|
atuin.flags = [ "--disable-ctrl-r" "--disable-up-arrow" ];
|
||||||
|
bash = {
|
||||||
|
enable = true;
|
||||||
|
enableCompletion = false;
|
||||||
|
};
|
||||||
|
zsh.enable = true;
|
||||||
|
fish.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Needed to avoid error with dummy fish package.
|
||||||
|
xdg.dataFile."fish/home-manager_generated_completions".source =
|
||||||
|
lib.mkForce (builtins.toFile "empty" "");
|
||||||
|
|
||||||
|
test.stubs = {
|
||||||
|
atuin = { };
|
||||||
|
bash-preexec = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.bashrc
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.bashrc \
|
||||||
|
"eval \"\$(@atuin@/bin/atuin init bash '--disable-ctrl-r' '--disable-up-arrow')\""
|
||||||
|
|
||||||
|
assertFileExists home-files/.zshrc
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.zshrc \
|
||||||
|
"eval \"\$(@atuin@/bin/atuin init zsh '--disable-ctrl-r' '--disable-up-arrow')\""
|
||||||
|
assertFileExists home-files/.config/fish/config.fish
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/fish/config.fish \
|
||||||
|
"@atuin@/bin/atuin init fish --disable-ctrl-r --disable-up-arrow | source"
|
||||||
|
'';
|
||||||
|
}
|
|
@ -15,6 +15,6 @@
|
||||||
assertFileExists home-files/.zshrc
|
assertFileExists home-files/.zshrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.zshrc \
|
home-files/.zshrc \
|
||||||
'eval "$(@atuin@/bin/atuin init zsh)"'
|
'eval "$(@atuin@/bin/atuin init zsh )"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue