Skip to content

Commit 2a3d37b

Browse files
committed
main: Add ZSH_HIGHLIGHT_DIRS_BLACKLIST
Closes zsh-users#379.
1 parent 0369283 commit 2a3d37b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

highlighters/main/main-highlighter.zsh

+15-1
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,27 @@ _zsh_highlight_main_highlighter_highlight_path_separators()
756756
_zsh_highlight_main_highlighter_check_path()
757757
{
758758
_zsh_highlight_main_highlighter_expand_path $arg;
759-
local expanded_path="$REPLY"
759+
local expanded_path="$REPLY" tmp_path
760760

761761
REPLY=path
762762

763763
[[ -z $expanded_path ]] && return 1
764764
[[ -L $expanded_path ]] && return 0
765765
[[ -e $expanded_path ]] && return 0
766766

767+
# Check if this is a disallowed path
768+
if [[ $expanded_path[1] == / ]]; then
769+
tmp_path=$expanded_path
770+
else
771+
tmp_path=$PWD/$expanded_path
772+
fi
773+
tmp_path=$tmp_path:a
774+
775+
while [[ $tmp_path != / ]]; do
776+
[[ -z "${tmp_path:|ZSH_HIGHLIGHT_DIRS_BLACKLIST}" ]] && return 1
777+
tmp_path=$tmp_path:h
778+
done
779+
767780
# Search the path in CDPATH
768781
local cdpath_dir
769782
for cdpath_dir in $cdpath ; do
@@ -1063,3 +1076,4 @@ else
10631076
# Make sure the cache is unset
10641077
unset _zsh_highlight_main__command_type_cache
10651078
fi
1079+
typeset -ga ZSH_HIGHLIGHT_DIRS_BLACKLIST

0 commit comments

Comments
 (0)