1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 03:09:47 +01:00

zsh: generalize zsh-history-substring-search

Specifically, allow variable expansion for the key codes by switching
from single to double quotes.

This also adds a helpful suggestion to descriptions. Taken from the
project's README, see

  4abed97b6e/README.md (L71-L74))
This commit is contained in:
Kiran Ostrolenk 2023-10-10 18:09:38 +01:00 committed by Mikilio
parent ebc04f9b62
commit 5d13d826a0
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 9 additions and 7 deletions

View file

@ -204,7 +204,8 @@ let
default = [ "^[[A" ];
description = ''
The key codes to be used when searching up.
The default of `^[[A` corresponds to the UP key.
The default of `^[[A` may correspond to the UP key -- if not, try
`$terminfo[kcuu1]`.
'';
};
searchDownKey = mkOption {
@ -212,7 +213,8 @@ let
default = [ "^[[B" ];
description = ''
The key codes to be used when searching down.
The default of `^[[B` corresponds to the DOWN key.
The default of `^[[B` may correspond to the DOWN key -- if not, try
`$terminfo[kcud1]`.
'';
};
};
@ -635,11 +637,11 @@ in
''
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
${lib.concatMapStringsSep "\n"
(upKey: "bindkey '${upKey}' history-substring-search-up")
(upKey: "bindkey \"${upKey}\" history-substring-search-up")
(lib.toList cfg.historySubstringSearch.searchUpKey)
}
${lib.concatMapStringsSep "\n"
(downKey: "bindkey '${downKey}' history-substring-search-down")
(downKey: "bindkey \"${downKey}\" history-substring-search-down")
(lib.toList cfg.historySubstringSearch.searchDownKey)
}
'')

View file

@ -17,9 +17,9 @@ with lib;
# 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$"
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$"
'';
};
}