Skip to content

Commit d305eec

Browse files
committed
zsh: fix zsh history substring search generation
Signed-off-by: Austin Horstman <[email protected]>
1 parent bcccb01 commit d305eec

File tree

2 files changed

+9
-41
lines changed

2 files changed

+9
-41
lines changed

modules/programs/zsh/history.nix

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -247,28 +247,12 @@ in
247247
# https://github.com/zsh-users/zsh-history-substring-search#usage
248248
''
249249
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
250-
251-
${
252-
let
253-
upKeys = lib.toList cfg.historySubstringSearch.searchUpKey;
254-
downKeys = lib.toList cfg.historySubstringSearch.searchDownKey;
255-
in
256-
''
257-
# Bind search up keys
258-
${lib.hm.zsh.define "search_up_keys" upKeys}
259-
for key in "''${search_up_keys[@]}"; do
260-
bindkey "$key" history-substring-search-up
261-
done
262-
unset key search_up_keys
263-
264-
# Bind search down keys
265-
${lib.hm.zsh.define "search_down_keys" downKeys}
266-
for key in "''${search_down_keys[@]}"; do
267-
bindkey "$key" history-substring-search-down
268-
done
269-
unset key search_down_keys
270-
''
271-
}
250+
${lib.concatMapStringsSep "\n" (upKey: ''bindkey "${upKey}" history-substring-search-up'') (
251+
lib.toList cfg.historySubstringSearch.searchUpKey
252+
)}
253+
${lib.concatMapStringsSep "\n" (downKey: ''bindkey "${downKey}" history-substring-search-down'') (
254+
lib.toList cfg.historySubstringSearch.searchDownKey
255+
)}
272256
''
273257
))
274258
];

tests/modules/programs/zsh/history-substring-search-expected.zshrc

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,6 @@ done
3636
unset opt disabled_opts
3737

3838
source @zsh-history-substring-search@/share/zsh-history-substring-search/zsh-history-substring-search.zsh
39-
40-
# Bind search up keys
41-
search_up_keys=(
42-
'^[[A' '\eOA'
43-
)
44-
for key in "${search_up_keys[@]}"; do
45-
bindkey "$key" history-substring-search-up
46-
done
47-
unset key search_up_keys
48-
49-
# Bind search down keys
50-
search_down_keys=(
51-
'^[[B'
52-
)
53-
for key in "${search_down_keys[@]}"; do
54-
bindkey "$key" history-substring-search-down
55-
done
56-
unset key search_down_keys
57-
39+
bindkey "^[[A" history-substring-search-up
40+
bindkey "\eOA" history-substring-search-up
41+
bindkey "^[[B" history-substring-search-down

0 commit comments

Comments
 (0)