olets / zsh-abbr

The zsh manager for auto-expanding abbreviations, inspired by fish. ~13,000 unique cloners as of May '24, 580+ Homebrew installs 6/23-6/24
https://zsh-abbr.olets.dev
Other
510 stars 18 forks source link

Possible to integrate with zsh-syntax-highlighting? #23

Closed Herjar closed 3 years ago

Herjar commented 3 years ago

When I use an alias, e.g. alias gst="git status", zsh-syntax-highlighting shows if it is a valid command/alias like this: image

When I define the same with zsh-abbr it looks invalid: image

Is it possible to get the same validation with zsh-abbr?

olets commented 3 years ago

Let me know if these work for you. Works in my Ubuntu VM but it'd be nice to get that WSL2 confirmation before I add them to the README. h/t https://github.com/olets/zsh-abbr/issues/20 for getting me started

# in .zshrc

typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main regexp)
# the next two lines must come after zsh-abbr
ZSH_HIGHLIGHT_REGEXP=('^[[:blank:][:space:]]*('${(j:|:)${(k)ABBR_REGULAR_USER_ABBREVIATIONS}}')$' fg=blue)
ZSH_HIGHLIGHT_REGEXP+=('\<('${(j:|:)${(k)ABBR_GLOBAL_USER_ABBREVIATIONS}}')$' fg=yellow)
% abbr x=test
% abbr -g y=test
% x # should be blue
% <space>x # should be blue
% <tab>x # should be blue
% x; # should not color
% a x # should not color
%
x # should be blue (alt-enter for a line break)
% a
x # should not color
% y # should be yellow
% <space>y # should be yellow
% <tab>y # should be yellow
% y; # should not color
% a y # should be yellow
%
y # should be yellow (alt-enter for a line break)
% a
y # should be yellow

You can customize the fg= bits to meet your needs

Herjar commented 3 years ago

It works great :rocket:

Thank you!

olets commented 3 years ago

This is now in the README!