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:
+6
-1
@@ -90,7 +90,12 @@ Each is enabled only when the binary is present (`command -v`):
|
||||
|
||||
## Eza Hyperlinks — Implementation Note
|
||||
|
||||
`zshrc` does **not** set the oh-my-zsh `eza` plugin's `hyperlink` zstyle. The plugin emits a bare `--hyperlink` flag, which eza (clap) treats as taking the *next token* as its optional value — so `la /` fails with `invalid value '/'`. Instead, after oh-my-zsh loads, the aliases are rewritten to append the glued `--hyperlink=always` form, which can't eat a following path argument. Hyperlinks stay on and paths keep working.
|
||||
`zshrc` does **not** set the oh-my-zsh `eza` plugin's `hyperlink` zstyle (the plugin's bare `--hyperlink` causes issues). Instead, after oh-my-zsh loads, the aliases are rewritten to append the correct hyperlink flag for the installed eza version:
|
||||
|
||||
- **Newer eza** (help shows `--hyperlink [<WHEN>]`): the oh-my-zsh plugin's bare `--hyperlink` is treated by clap as taking the *next token* as its optional value, so `la /` fails with `invalid value '/'`. We append the glued `--hyperlink=always` form, which can't eat a following path argument.
|
||||
- **Older eza** (e.g. Debian's, where `--hyperlink` is a pure boolean): `--hyperlink=always` is rejected with `Flag --hyperlink cannot take a value`. We detect this via `eza --help` and fall back to the bare `--hyperlink`, which is safe here because boolean flags don't consume the next token (the path-eating bug doesn't apply).
|
||||
|
||||
Detection runs once at shell start via `eza --help | grep '<WHEN>'`; the right form is applied to every eza alias. Hyperlinks stay on and paths keep working across eza versions.
|
||||
|
||||
## Auto-Update Behavior
|
||||
|
||||
|
||||
Reference in New Issue
Block a user