[Bug report] Abbreviations with regex characters break syntax highlighting
Is there an existing issue for this?
- [x] I have searched the existing issues
Update the issue title
- [x] I have updated the title
Expected Behavior
I have some aliases that end in +, a signal to me that they "force" something. For example:
❯ grep '+"' $ABBR_USER_ABBREVIATIONS_FILE
abbr -g "git p+"="git push origin +\"\$(git branch --show-current)\""
abbr "rm+"="rm -rfv"
Separately, I also have syntax highlighting enabled pretty much exactly as recommended in the documentation:
The expectation was that this should trigger highlighting whenever I type my abbreviations:
❯ rm+
❯ git p+
Actual Behavior
However, the presence of + in my abbreviation seems to confuse the highlighting algorithm. Specifically, it seems to treat this as a regex repetition operator, not as a literal plus. As a result, e.g., rm+ is not highlighted, meanwhile all of the following are highlighted (note: none of these are abbreviations):
rm
rmm
rmmm
rmmmm
rmmmmmmmmmmmmmmmm
git p
git ppppp
Steps To Reproduce
Source this on terminal startup (e.g., from .zshrc):
(( "${#ABBR_REGULAR_USER_ABBREVIATIONS}" )) && {
ABBR_HIGHLIGHTS="fg=black,bold,bg=cyan"
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(regexp)
ZSH_HIGHLIGHT_REGEXP=('^[[:blank:][:space:]]*('${(j:|:)${(Qk)ABBR_REGULAR_USER_ABBREVIATIONS}}')$' "${ABBR_HIGHLIGHTS}")
ZSH_HIGHLIGHT_REGEXP+=('[[:<:]]('${(j:|:)${(Qk)ABBR_GLOBAL_USER_ABBREVIATIONS}}')$' "${ABBR_HIGHLIGHTS}")
}
Environment
❯ abbr profile
zsh-abbr version 6.4.0
zsh 5.9 (arm64-apple-darwin25.0)
OSTYPE darwin25.0
Installation method
Homebrew
Installation method details
No response
Anything else?
If this is corner case could be handled on zsh-abbr's side, that would be ideal.
However, I suspect the patch must reside within zsh-syntax-highlighting. In that case, perhaps you could at least acknowledge this behavior in the Known limitations block of the documentation.