Files
RedBear-OS/recipes/shells/zsh/source/Functions/Zle/which-command
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

43 lines
1.0 KiB
Plaintext

zmodload -i zsh/parameter zsh/zutil
zle -I
local -a whencecmd wds
# Set the whence style to your favourite function
# (but NOT which-command!)
zstyle -a :zle:$WIDGET whence whencecmd || whencecmd=(whence -c --)
wds=(${(z)LBUFFER})
local wd barewd
local -A seen
while true; do
wd=${wds[1]}
barewd=${(Q)wd}
if [[ $barewd != $wd || -n $seen[$barewd] ]]; then
# quoted or already expanded, see if original word is an alias...
if [[ -z $seen[$barewd] && -n $aliases[$wd] ]]; then
# yes, so we need to decode that, with no extra expansion...
$whencecmd $wd
seen[$wd]=1
wds=(${(z)aliases[$wd]})
continue
else
# use unquoted word, don't expand alias
(unalias -- $barewd 2>/dev/null; $whencecmd $barewd)
fi
else
# turn on globsubst for =ls etc.
$whencecmd ${~barewd}
if [[ -n $aliases[$barewd] && -z $seen[$barewd] ]]; then
# Recursively expand aliases
seen[$barewd]=1
wds=(${(z)aliases[$barewd]})
continue
fi
fi
break
done