41
41
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:= none}
42
42
: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:= fg=green}
43
43
: ${ZSH_HIGHLIGHT_STYLES[path]:= underline}
44
+ : ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:= underline}
44
45
: ${ZSH_HIGHLIGHT_STYLES[path_prefix]:= underline}
46
+ : ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:= underline}
45
47
: ${ZSH_HIGHLIGHT_STYLES[globbing]:= fg=blue}
46
48
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:= fg=blue}
47
49
: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:= none}
@@ -216,6 +218,7 @@ _zsh_highlight_main_highlighter()
216
218
# which add the entry early so escape sequences within the string override
217
219
# the string's color.
218
220
integer already_added=0
221
+ integer path_found=0
219
222
local style_override=" "
220
223
if [[ $this_word == * ' :start:' * ]]; then
221
224
in_array_assignment=false
@@ -380,6 +383,7 @@ _zsh_highlight_main_highlighter()
380
383
else
381
384
if _zsh_highlight_main_highlighter_check_path; then
382
385
style=$ZSH_HIGHLIGHT_STYLES [path]
386
+ path_found=1
383
387
else
384
388
style=$ZSH_HIGHLIGHT_STYLES [unknown-token]
385
389
fi
@@ -428,6 +432,7 @@ _zsh_highlight_main_highlighter()
428
432
else
429
433
if _zsh_highlight_main_highlighter_check_path; then
430
434
style=$ZSH_HIGHLIGHT_STYLES [path]
435
+ path_found=1
431
436
else
432
437
style=$ZSH_HIGHLIGHT_STYLES [default]
433
438
fi
@@ -437,7 +442,10 @@ _zsh_highlight_main_highlighter()
437
442
fi
438
443
# if a style_override was set (eg in _zsh_highlight_main_highlighter_check_path), use it
439
444
[[ -n $style_override ]] && style=$ZSH_HIGHLIGHT_STYLES [$style_override ]
440
- (( already_added )) || _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
445
+ if ! (( already_added )) ; then
446
+ _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
447
+ (( path_found )) && _zsh_highlight_main_highlighter_highlight_path_separators
448
+ fi
441
449
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:# " $arg " } ]]; then
442
450
next_word=' :start:'
443
451
highlight_glob=true
@@ -466,6 +474,18 @@ _zsh_highlight_main_highlighter_check_assign()
466
474
[[ $arg == [[:alpha:]_][[:alnum:]_]# (|\[*\])(|[+])=* ]]
467
475
}
468
476
477
+ _zsh_highlight_main_highlighter_highlight_path_separators ()
478
+ {
479
+ local pos style_pathsep
480
+ style_pathsep=$ZSH_HIGHLIGHT_STYLES [${style_override:- path} _pathseparator]
481
+ [[ -z " $style " || " $style " == " $style_pathsep " ]] && return 0
482
+ for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do
483
+ if [[ $BUFFER [pos+1] == / ]]; then
484
+ _zsh_highlight_main_add_region_highlight $pos $(( pos + 1 )) $style_pathsep
485
+ fi
486
+ done
487
+ }
488
+
469
489
# Check if $arg is a path.
470
490
_zsh_highlight_main_highlighter_check_path ()
471
491
{
0 commit comments