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

zsh: add option for zsh-history-substring-search (#3156)

This commit is contained in:
Kiran 2022-09-13 21:06:52 +01:00 committed by GitHub
parent 9f7fe353b6
commit 60c6bfe322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,6 +188,28 @@ let
};
};
historySubstringSearchModule = types.submodule {
options = {
enable = mkEnableOption "history substring search";
searchUpKey = mkOption {
type = types.str;
default = "^[[A";
description = ''
The key code to be used when searching up.
The default of <literal>^[[A</literal> corresponds to the UP key.
'';
};
searchDownKey = mkOption {
type = types.str;
default = "^[[B";
description = ''
The key code to be used when searching down.
The default of <literal>^[[B</literal> corresponds to the DOWN key.
'';
};
};
};
in
{
@ -295,6 +317,12 @@ in
description = "Enable zsh syntax highlighting";
};
historySubstringSearch = mkOption {
type = historySubstringSearchModule;
default = {};
description = "Options related to zsh-history-substring-search.";
};
history = mkOption {
type = historyModule;
default = {};
@ -555,10 +583,18 @@ in
${dirHashesStr}
${optionalString cfg.enableSyntaxHighlighting
# Load zsh-syntax-highlighting last, after all custom widgets have been created
# Load zsh-syntax-highlighting after all custom widgets have been created
# https://github.com/zsh-users/zsh-syntax-highlighting#faq
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
}
${optionalString (cfg.historySubstringSearch.enable or false)
# Load zsh-history-substring-search after zsh-syntax-highlighting
# 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
''}
'';
}