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