main: support highlighting paths with specific styles
If there are styles starting with `*.`, consider these "glob matchers" and style according to the matching glob. This allows users to color paths matching patterns in any way desired. Fixes: #605
This commit is contained in:
parent
99680ff695
commit
f39e4bbdfb
|
|
@ -5,6 +5,10 @@
|
||||||
[#942]
|
[#942]
|
||||||
- Highlight redirection targets as paths if possible [#982].
|
- Highlight redirection targets as paths if possible [#982].
|
||||||
|
|
||||||
|
## Highlight paths with matching patterns
|
||||||
|
|
||||||
|
When matchers start with `*.`, the are treated as globs to further refine thee
|
||||||
|
highlighting of paths [#982].
|
||||||
|
|
||||||
# Changes in 0.8.0
|
# Changes in 0.8.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ This highlighter defines the following styles:
|
||||||
* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command).
|
* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command).
|
||||||
* `default` - everything else
|
* `default` - everything else
|
||||||
|
|
||||||
|
Additionally, styles starting with `*.` may be used to style `path` and
|
||||||
|
`redirection` argument matches with a more specific style. For example,
|
||||||
|
defining the `*.png` style will apply to any `path` or `redirection` target
|
||||||
|
ending with `.png`.
|
||||||
|
|
||||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
for example in `~/.zshrc`:
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1258,6 +1258,16 @@ _zsh_highlight_main_highlighter_check_path()
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -L $expanded_path || -e $expanded_path ]]; then
|
if [[ -L $expanded_path || -e $expanded_path ]]; then
|
||||||
|
for key in ${(k)ZSH_HIGHLIGHT_STYLES}; do
|
||||||
|
case $key in
|
||||||
|
"*."*) ;;
|
||||||
|
*) continue ;;
|
||||||
|
esac
|
||||||
|
case $arg in
|
||||||
|
*.$key[3,-1]) REPLY=$key ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue