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]:= }
@@ -111,6 +112,7 @@ _zsh_highlight_main_calculate_fallback() {
111
112
command arg0
112
113
precommand arg0
113
114
hashed-command arg0
115
+ autodirectory arg0
114
116
arg0_\* arg0
115
117
116
118
# TODO: Maybe these? —
@@ -1121,6 +1123,8 @@ _zsh_highlight_main_highlighter_check_path()
1121
1123
fi
1122
1124
1123
1125
if (( in_command_position )) ; then
1126
+ # ### Currently, this value is never returned: either it's overwritten
1127
+ # ### below, or the return code is non-zero
1124
1128
REPLY=arg0
1125
1129
else
1126
1130
REPLY=path
@@ -1142,8 +1146,16 @@ _zsh_highlight_main_highlighter_check_path()
1142
1146
done
1143
1147
1144
1148
if (( in_command_position )) ; then
1145
- if [[ -x $expanded_path ]] && { (( autocd )) || [[ ! -d $expanded_path ]] }; then
1146
- return 0
1149
+ if [[ -x $expanded_path ]]; then
1150
+ if (( autocd )) ; then
1151
+ if [[ -d $expanded_path ]]; then
1152
+ REPLY=autodirectory
1153
+ fi
1154
+ return 0
1155
+ elif [[ ! -d $expanded_path ]]; then
1156
+ # ### This seems unreachable for the current callers
1157
+ return 0
1158
+ fi
1147
1159
fi
1148
1160
else
1149
1161
if [[ -L $expanded_path || -e $expanded_path ]]; then
@@ -1156,7 +1168,12 @@ _zsh_highlight_main_highlighter_check_path()
1156
1168
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
1157
1169
local cdpath_dir
1158
1170
for cdpath_dir in $cdpath ; do
1159
- [[ -d " $cdpath_dir /$expanded_path " && -x " $cdpath_dir /$expanded_path " ]] && return 0
1171
+ if [[ -d " $cdpath_dir /$expanded_path " && -x " $cdpath_dir /$expanded_path " ]]; then
1172
+ if (( in_command_position && autocd )) ; then
1173
+ REPLY=autodirectory
1174
+ fi
1175
+ return 0
1176
+ fi
1160
1177
done
1161
1178
fi
1162
1179
0 commit comments