carapace-sh / carapace-bin

multi-shell multi-command argument completer
https://carapace.sh
MIT License
964 stars 53 forks source link

Error with ls when aliased to eza #2601

Open mathomp4 opened 3 days ago

mathomp4 commented 3 days ago

Current Behavior

I freely admit this is probably due to my setup, but I'm not sure what is happening and if I can fix it.

When I try and do tab completion with ls I get:

❯ ls
invalid argument "all" for "--color-scale" flag: strconv.ParseBool: parsing "all": invalid syntax

I can confirm carapace is doing this because if I comment out the:

export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
zstyle ':completion:*:git:*' group-order 'main commands' 'alias commands' 'external commands'
source <(carapace _carapace)

bits of my .zshrc, it doesn't throw the error.

Now for the the exciting bits. My ls is not ls. My ls is:

COMMON_EZA_OPTIONS='--classify --icons --color=automatic --color-scale=all --header --group'
alias ls="eza $COMMON_EZA_OPTIONS --grid"

and if I turn that off, tab completion also works.

So, I guess my question is: Is there a way I can tell carapace that my ls is actually eza?

Expected Behavior

I guess have carapace know that my ls is actually eza.

Steps To Reproduce

This is how my system is setup:

  1. Set up carapace in zshrc with:
    export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional
    zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
    zstyle ':completion:*:git:*' group-order 'main commands' 'alias commands' 'external commands'
    source <(carapace _carapace)
  2. Set EZA up with:
    COMMON_EZA_OPTIONS='--classify --icons --color=automatic --color-scale=all --header --group'
    alias ls="eza $COMMON_EZA_OPTIONS --grid"
  3. Try doing ls <tab>

Version

develop (brew says 1.0.7)

OS

Shell

Anything else?

No response

Polar

Fund with Polar

rsteube commented 3 days ago

Yes, I'm using eza as well:

  1. use carapace to create an alias instead of using your shell

    # yaml-language-server: $schema=https://carapace.sh/schemas/command.json
    name: ls
    run: "[eza]"
  2. or bridge the completion

    # yaml-language-server: $schema=https://carapace.sh/schemas/command.json
    name: ls
    parsing: disabled
    completion:
    positionalany: ["$carapace.bridge.CarapaceBin([eza])"]
rsteube commented 3 days ago

btw. this should also work (and be preferred as it let's carapace know the flags are already set):

yaml-language-server: $schema=https://carapace.sh/schemas/command.json
name: ls
run: "[eza, --classify, --icons, --color=automatic, --color-scale=all, --header, --group]"

It's just that it seems the --color-scale flag is currently wrong in carapace - gotta fix that.

same for 2.:

# yaml-language-server: $schema=https://carapace.sh/schemas/command.json
name: ls
parsing: disabled
completion:
  positionalany: ["$carapace.bridge.CarapaceBin([eza, --classify, --icons, --color=automatic, --color-scale=all, --header, --group])"]
mathomp4 commented 3 days ago

Sooooo...let's assume I'm quite new at carapace, which I am. Where do I make these changes?

Would it be in ~/.config/carapace/bridges.yaml? I mean, it seems to work (if I remove --color-scale=all from my options), but I want to be sure. 😄

rsteube commented 3 days ago

~/.config/carapace/specs/ls.yaml but only on linux or if you use XDG_CONFIG_HOME. Darwin has it under $HOME/Library/Application Support/....

See carapace --help to be sure: "Specs are loaded from [...]"