Open zaidhaan opened 1 year ago
I think we can take the CDABLE_VARS documentation fairly literally
If the argument to a cd command (or an implied cd with the
AUTO_CD option set) is not a directory, and does not begin with
a slash, try to expand the expression as if it were preceded by
a `~' (see the section `Filename Expansion').
and just call _zsh_highlight_main_highlighter_expand_path
again, but prefixed with a tilde. Something like
elif (( autocd && cdablevars )) && [[ ${1[1]} != / ]]; then
_zsh_highlight_main_highlighter_expand_path "~$1"
if [[ -d $REPLY && -x $REPLY ]]; then
REPLY=autodirectory
return 0
fi
That covers the case where the path continues and the case where a username is provided.
See #930 (or at least just https://github.com/zsh-users/zsh-syntax-highlighting/issues/930#issuecomment-1590633859).
What this PR does:
foo
exists and the path it resolves to also exists, it will highlight it as ahashed-command
What this PR does not do:
If this feels like enough to be a PR on its own, then you could merge. If it feels incomplete, but on the right path, someone else could offer guidance and I'll see if I can complete it or they could pick it up themselves, or if it's completely wrong then it could just be closed.