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}
@@ -271,6 +273,7 @@ _zsh_highlight_main_highlighter()
271
273
# which add the entry early so escape sequences within the string override
272
274
# the string's color.
273
275
integer already_added=0
276
+ integer path_found=0
274
277
local style_override=" "
275
278
if [[ $this_word == * ' :start:' * ]]; then
276
279
in_array_assignment=false
@@ -457,6 +460,7 @@ _zsh_highlight_main_highlighter()
457
460
else
458
461
if _zsh_highlight_main_highlighter_check_path; then
459
462
style=path
463
+ path_found=1
460
464
else
461
465
style=unknown-token
462
466
fi
@@ -508,6 +512,7 @@ _zsh_highlight_main_highlighter()
508
512
else
509
513
if _zsh_highlight_main_highlighter_check_path; then
510
514
style=path
515
+ path_found=1
511
516
else
512
517
style=default
513
518
fi
@@ -517,7 +522,10 @@ _zsh_highlight_main_highlighter()
517
522
fi
518
523
# if a style_override was set (eg in _zsh_highlight_main_highlighter_check_path), use it
519
524
[[ -n $style_override ]] && style=$style_override
520
- (( already_added )) || _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
525
+ if ! (( already_added )) ; then
526
+ _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
527
+ (( path_found )) && _zsh_highlight_main_highlighter_highlight_path_separators
528
+ fi
521
529
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:# " $arg " } ]]; then
522
530
next_word=' :start:'
523
531
highlight_glob=true
@@ -546,6 +554,18 @@ _zsh_highlight_main_highlighter_check_assign()
546
554
[[ $arg == [[:alpha:]_][[:alnum:]_]# (|\[*\])(|[+])=* ]]
547
555
}
548
556
557
+ _zsh_highlight_main_highlighter_highlight_path_separators ()
558
+ {
559
+ local pos style_pathsep
560
+ style_pathsep=${style_override:- path} _pathseparator
561
+ [[ -z " $style_pathsep " || " $style " == " $style_pathsep " ]] && return 0
562
+ for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do
563
+ if [[ $BUFFER [pos+1] == / ]]; then
564
+ _zsh_highlight_main_add_region_highlight $pos $(( pos + 1 )) $style_pathsep
565
+ fi
566
+ done
567
+ }
568
+
549
569
# Check if $arg is a path.
550
570
_zsh_highlight_main_highlighter_check_path ()
551
571
{
0 commit comments