mirror of
				https://github.com/zsh-users/zsh-syntax-highlighting.git
				synced 2025-10-30 15:56:28 +08:00 
			
		
		
		
	highlight path separators
This commit is contained in:
		
							parent
							
								
									5320f1e18d
								
							
						
					
					
						commit
						4b6fbaa221
					
				@ -41,6 +41,7 @@
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[path_separator]:=fg=cyan}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix]:=underline}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[path_approx]:=fg=yellow,underline}
 | 
			
		||||
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
 | 
			
		||||
@ -127,6 +128,7 @@ _zsh_highlight_main_highlighter()
 | 
			
		||||
                          style=$ZSH_HIGHLIGHT_STYLES[assign]
 | 
			
		||||
                          new_expression=true
 | 
			
		||||
                        elif _zsh_highlight_main_highlighter_check_path; then
 | 
			
		||||
                          _zsh_highlight_main_highlighter_highlight_path_separators
 | 
			
		||||
                          style=$ZSH_HIGHLIGHT_STYLES[path]
 | 
			
		||||
                        elif [[ $arg[0,1] = $histchars[0,1] ]]; then
 | 
			
		||||
                          style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
 | 
			
		||||
@ -149,6 +151,7 @@ _zsh_highlight_main_highlighter()
 | 
			
		||||
        '`'*'`') style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
 | 
			
		||||
        *"*"*)   $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
 | 
			
		||||
        *)       if _zsh_highlight_main_highlighter_check_path; then
 | 
			
		||||
                   _zsh_highlight_main_highlighter_highlight_path_separators
 | 
			
		||||
                   style=$ZSH_HIGHLIGHT_STYLES[path]
 | 
			
		||||
                 elif [[ $arg[0,1] = $histchars[0,1] ]]; then
 | 
			
		||||
                   style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
 | 
			
		||||
@ -175,6 +178,19 @@ _zsh_highlight_main_highlighter_check_assign()
 | 
			
		||||
    [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])=* ]]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_zsh_highlight_main_highlighter_highlight_path_separators()
 | 
			
		||||
{
 | 
			
		||||
  local pos style
 | 
			
		||||
  style=$ZSH_HIGHLIGHT_STYLES[path_separator]
 | 
			
		||||
  for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do
 | 
			
		||||
    local char="$BUFFER[pos+1]"
 | 
			
		||||
 | 
			
		||||
    if [[ "$char" == "/" ]]; then
 | 
			
		||||
      region_highlight+=("$pos $((pos + 1)) $style")
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Check if the argument is a path.
 | 
			
		||||
_zsh_highlight_main_highlighter_check_path()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user