diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 145d7f79..c4520e7a 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -236,6 +236,16 @@ let ''; }; + patterns = mkOption { + type = types.attrsOf types.str; + default = {}; + example = { "rm -rf *" = "fg=white,bold,bg=red"; }; + description = '' + Custom syntax highlighting for user-defined patterns. + Reference: + ''; + }; + styles = mkOption { type = types.attrsOf types.str; default = {}; @@ -673,6 +683,11 @@ in (name: value: "ZSH_HIGHLIGHT_STYLES+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})") cfg.syntaxHighlighting.styles )} + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList + (name: value: "ZSH_HIGHLIGHT_PATTERNS+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})") + cfg.syntaxHighlighting.patterns + )} '') (optionalString (cfg.historySubstringSearch.enable or false) diff --git a/tests/modules/programs/zsh/syntax-highlighting.nix b/tests/modules/programs/zsh/syntax-highlighting.nix index 9baf1e43..981cefb6 100644 --- a/tests/modules/programs/zsh/syntax-highlighting.nix +++ b/tests/modules/programs/zsh/syntax-highlighting.nix @@ -11,6 +11,7 @@ with lib; package = pkgs.hello; highlighters = [ "brackets" "pattern" "cursor" ]; styles.comment = "fg=#6c6c6c"; + patterns."rm -rf *" = "fg=white,bold,bg=red"; }; };