35
35
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:= fg=green,underline}
36
36
: ${ZSH_HIGHLIGHT_STYLES[precommand]:= fg=green,underline}
37
37
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:= none}
38
+ : ${ZSH_HIGHLIGHT_STYLES[autodirectory]:= fg=green,underline}
38
39
: ${ZSH_HIGHLIGHT_STYLES[path]:= underline}
39
40
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:= }
40
41
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:= }
@@ -110,6 +111,7 @@ _zsh_highlight_main_calculate_fallback() {
110
111
command arg0
111
112
precommand arg0
112
113
hashed-command arg0
114
+ autodirectory arg0
113
115
arg0_\* arg0
114
116
115
117
path_prefix path
@@ -1092,6 +1094,8 @@ _zsh_highlight_main_highlighter_check_path()
1092
1094
fi
1093
1095
1094
1096
if (( in_command_position )) ; then
1097
+ # ### Currently, this value is never returned: either it's overwritten
1098
+ # ### below, or the return code is non-zero
1095
1099
REPLY=arg0
1096
1100
else
1097
1101
REPLY=path
@@ -1113,8 +1117,16 @@ _zsh_highlight_main_highlighter_check_path()
1113
1117
done
1114
1118
1115
1119
if (( in_command_position )) ; then
1116
- if [[ -x $expanded_path ]] && { (( autocd )) || [[ ! -d $expanded_path ]] }; then
1117
- return 0
1120
+ if [[ -x $expanded_path ]]; then
1121
+ if (( autocd )) ; then
1122
+ if [[ -d $expanded_path ]]; then
1123
+ REPLY=autodirectory
1124
+ fi
1125
+ return 0
1126
+ elif [[ ! -d $expanded_path ]]; then
1127
+ # ### This seems unreachable for the current callers
1128
+ return 0
1129
+ fi
1118
1130
fi
1119
1131
else
1120
1132
if [[ -L $expanded_path || -e $expanded_path ]]; then
@@ -1127,7 +1139,12 @@ _zsh_highlight_main_highlighter_check_path()
1127
1139
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
1128
1140
local cdpath_dir
1129
1141
for cdpath_dir in $cdpath ; do
1130
- [[ -d " $cdpath_dir /$expanded_path " && -x " $cdpath_dir /$expanded_path " ]] && return 0
1142
+ if [[ -d " $cdpath_dir /$expanded_path " && -x " $cdpath_dir /$expanded_path " ]]; then
1143
+ if (( in_command_position && autocd )) ; then
1144
+ REPLY=autodirectory
1145
+ fi
1146
+ return 0
1147
+ fi
1131
1148
done
1132
1149
fi
1133
1150
0 commit comments