zsh: detect eza --hyperlink capability, fix 'cannot take a value' on Debian's older eza
Newer eza (clap) treats --hyperlink as taking an optional value, so the oh-my-zsh plugin's bare --hyperlink eats the next path arg (la / -> invalid value '/'). The previous fix glued --hyperlink=always to avoid that. But Debian ships an older eza where --hyperlink is a pure boolean that rejects a value, so --hyperlink=always errors with 'Flag --hyperlink cannot take a value'. Detect the installed eza's behavior via 'eza --help | grep <WHEN>': - newer eza: use --hyperlink=always (glued, avoids path-eating) - older eza: use bare --hyperlink (boolean, doesn't eat tokens so the original bug doesn't apply) Apply the chosen form to every eza alias. Both paths keep hyperlinks on and paths working.
This commit is contained in:
@@ -132,13 +132,22 @@ zstyle ':completion:*' special-dirs true
|
||||
|
||||
source $OHMYZSH/oh-my-zsh.sh
|
||||
|
||||
# Re-enable eza hyperlinks safely. The oh-my-zsh eza plugin's bare
|
||||
# --hyperlink flag eats the following path argument (eza clap optional-value),
|
||||
# so we append the glued --hyperlink=always form to each eza alias instead.
|
||||
# Re-enable eza hyperlinks, picking the flag form the installed eza supports.
|
||||
# Newer eza: --hyperlink takes an optional value; the oh-my-zsh plugin's bare
|
||||
# --hyperlink would eat the following path arg (e.g. `la /` -> invalid value '/'),
|
||||
# so we use the glued --hyperlink=always form.
|
||||
# Older eza (e.g. Debian's): --hyperlink is a pure boolean and rejects a value,
|
||||
# so --hyperlink=always errors; the bare --hyperlink is correct and safe there
|
||||
# (boolean flags don't consume the next token, so the path-eating bug doesn't
|
||||
# apply).
|
||||
_hl_flag="--hyperlink"
|
||||
if command -v eza >/dev/null && eza --help 2>&1 | grep -q -- '--hyperlink.*<WHEN>'; then
|
||||
_hl_flag="--hyperlink=always"
|
||||
fi
|
||||
for _ea in la ldot lD lDD ll ls lsd lsdl lS lT; do
|
||||
(( $+aliases[$_ea] )) && alias "$_ea"="${aliases[$_ea]} --hyperlink=always"
|
||||
(( $+aliases[$_ea] )) && alias "$_ea"="${aliases[$_ea]} $_hl_flag"
|
||||
done
|
||||
unset _ea
|
||||
unset _ea _hl_flag
|
||||
|
||||
# --- Tool integrations (self-configuring: enabled only when the tool exists) ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user