1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

atuin: add disable key options (#3754)

Co-authored-by: Janik H <janik@aq0.de>
This commit is contained in:
Janik 2023-03-15 11:52:48 +01:00 committed by GitHub
parent cae54dc45c
commit 215af6252d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 7 deletions

View file

@ -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
'';
};
}

View file

@ -18,6 +18,6 @@
assertFileExists home-files/.bashrc
assertFileContains \
home-files/.bashrc \
'eval "$(@atuin@/bin/atuin init bash)"'
'eval "$(@atuin@/bin/atuin init bash )"'
'';
}

View file

@ -5,4 +5,5 @@
atuin-fish = ./fish.nix;
atuin-no-shell = ./no-shell.nix;
atuin-zsh = ./zsh.nix;
atuin-set-flags = ./set-flags.nix;
}

View file

@ -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'
'';
}

View 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"
'';
}

View file

@ -15,6 +15,6 @@
assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'eval "$(@atuin@/bin/atuin init zsh)"'
'eval "$(@atuin@/bin/atuin init zsh )"'
'';
}