diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix
index f612aaaa..12d03645 100644
--- a/modules/programs/zsh.nix
+++ b/modules/programs/zsh.nix
@@ -190,18 +190,18 @@ let
options = {
enable = mkEnableOption "history substring search";
searchUpKey = mkOption {
- type = types.str;
- default = "^[[A";
+ type = with types; either (listOf str) str ;
+ default = [ "^[[A" ];
description = ''
- The key code to be used when searching up.
+ The key codes to be used when searching up.
The default of ^[[A corresponds to the UP key.
'';
};
searchDownKey = mkOption {
- type = types.str;
- default = "^[[B";
+ type = with types; either (listOf str) str ;
+ default = [ "^[[B" ];
description = ''
- The key code to be used when searching down.
+ The key codes to be used when searching down.
The default of ^[[B corresponds to the DOWN key.
'';
};
@@ -593,8 +593,14 @@ in
# https://github.com/zsh-users/zsh-history-substring-search#usage
''
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
- bindkey '${cfg.historySubstringSearch.searchUpKey}' history-substring-search-up
- bindkey '${cfg.historySubstringSearch.searchDownKey}' history-substring-search-down
+ ${lib.concatMapStringsSep "\n"
+ (upKey: "bindkey '${upKey}' history-substring-search-up")
+ (lib.toList cfg.historySubstringSearch.searchUpKey)
+ }
+ ${lib.concatMapStringsSep "\n"
+ (downKey: "bindkey '${downKey}' history-substring-search-down")
+ (lib.toList cfg.historySubstringSearch.searchDownKey)
+ }
'')
]);
}
diff --git a/tests/modules/programs/zsh/default.nix b/tests/modules/programs/zsh/default.nix
index 81e0d2d4..b9dc1b8c 100644
--- a/tests/modules/programs/zsh/default.nix
+++ b/tests/modules/programs/zsh/default.nix
@@ -5,5 +5,6 @@
zsh-history-path-old-default = ./history-path-old-default.nix;
zsh-history-path-old-custom = ./history-path-old-custom.nix;
zsh-history-ignore-pattern = ./history-ignore-pattern.nix;
+ zsh-history-substring-search = ./history-substring-search.nix;
zsh-prezto = ./prezto.nix;
}
diff --git a/tests/modules/programs/zsh/history-substring-search.nix b/tests/modules/programs/zsh/history-substring-search.nix
new file mode 100644
index 00000000..4e9054d9
--- /dev/null
+++ b/tests/modules/programs/zsh/history-substring-search.nix
@@ -0,0 +1,25 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ programs.zsh = {
+ enable = true;
+ historySubstringSearch = {
+ enable = true;
+ searchDownKey = "^[[B";
+ searchUpKey = [ "^[[A" "\\eOA" ];
+ };
+ };
+
+ test.stubs.zsh = { };
+
+ # Written with regex to ensure we don't end up missing newlines in the future
+ nmt.script = ''
+ assertFileRegex home-files/.zshrc "^bindkey '\^\[\[B' history-substring-search-down$"
+ assertFileRegex home-files/.zshrc "^bindkey '\^\[\[A' history-substring-search-up$"
+ assertFileRegex home-files/.zshrc "^bindkey '\\\\eOA' history-substring-search-up$"
+ '';
+ };
+}