More options to highlight path component

This commit is contained in:
Joe Rabinoff 2020-02-17 17:05:15 -05:00
parent d511fa39fa
commit b127a06e6f
2 changed files with 13 additions and 4 deletions

View File

@ -36,7 +36,7 @@ according to that style (following `LS_COLORS`):
* `sg` - files that have the sgid bit set
* `ow` - files that are world-writable
* `tw` - files that are world-writable and sticky
* `lp` - if set, the path-component of a filename is highlighted using this style
* `lp` - if set, the path component of a filename is highlighted using this style, unless it is set to `same`, in which case the path component is highlighted the same as the file
If a file would be highlighted `fi`, then it can be highlighted according to the
filename using `ZSH_HIGHLIGHT_FILE_PATTERNS` instead. This array has the form

View File

@ -219,11 +219,20 @@ _zsh_highlight_highlighter_files_paint()
fi
if [[ -n "$col" ]]; then
if (( end > start + $#basename && ${+ZSH_HIGHLIGHT_FILE_TYPES[lp]} )); then
if (( end > start + $#basename )); then
# There is a path component
if [[ $ZSH_HIGHLIGHT_FILE_TYPES[lp] = "same" ]]; then
region_highlight+=("$start $end $col")
else
if (( ${+ZSH_HIGHLIGHT_FILE_TYPES[lp]} )); then
region_highlight+=("$start $(( end - $#basename )) $ZSH_HIGHLIGHT_FILE_TYPES[lp]")
fi
region_highlight+=("$(( end - $#basename )) $end $col")
fi
else
region_highlight+=("$start $end $col")
fi
fi
start=$end
buf=${buf[$#word+1,-1]}