mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29: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 {
|
||||
type = with types;
|
||||
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.
|
||||
home.packages = [ cfg.package ];
|
||||
|
@ -91,18 +101,18 @@ in {
|
|||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
|
||||
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
|
||||
'';
|
||||
|
||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
if [[ $options[zle] = on ]]; then
|
||||
eval "$(${cfg.package}/bin/atuin init zsh)"
|
||||
eval "$(${cfg.package}/bin/atuin init zsh ${flagsStr})"
|
||||
fi
|
||||
'';
|
||||
|
||||
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
|
||||
assertFileContains \
|
||||
home-files/.bashrc \
|
||||
'eval "$(@atuin@/bin/atuin init bash)"'
|
||||
'eval "$(@atuin@/bin/atuin init bash )"'
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
atuin-fish = ./fish.nix;
|
||||
atuin-no-shell = ./no-shell.nix;
|
||||
atuin-zsh = ./zsh.nix;
|
||||
atuin-set-flags = ./set-flags.nix;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
assertFileExists home-files/.config/fish/config.fish
|
||||
assertFileContains \
|
||||
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
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'eval "$(@atuin@/bin/atuin init zsh)"'
|
||||
'eval "$(@atuin@/bin/atuin init zsh )"'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue