ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
22.66k stars 550 forks source link

Clap completion not installed #485

Open alecandido opened 1 year ago

alecandido commented 1 year ago

Still me, still about completion...

I tried to add:

eval $(zoxide init zsh)

but it doesn't add completion for the zoxide command.

For the time being, to obtain completion for zoxide command by downloading https://github.com/ajeetdsouza/zoxide/blob/main/contrib/completions/_zoxide with curl (of course the raw one).

Note: in case you might consider the other issues in light of this, I always tried with both

memark commented 1 year ago

How did you install zoxide? I'm assuming Homebrew going forward.

Are the completions not downloaded or just not loaded?

What is the output of brew info zoxide?

What is the output of ls $(brew --prefix)/share/zsh/site-functions?

alecandido commented 1 year ago

Wrong assumption: I used cargo install.

❯ cd .cargo/
❯ fd zoxide
bin/zoxide
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/_zoxide
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/zoxide.ts
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/zoxide.elv
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/zoxide.bash
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/_zoxide.ps1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/contrib/completions/zoxide.fish
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/zoxide.plugin.zsh
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide-remove.1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide-import.1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide.1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide-query.1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide-add.1
registry/src/github.com-1ecc6299db9ec823/zoxide-0.8.3/man/man1/zoxide-init.1
registry/cache/github.com-1ecc6299db9ec823/zoxide-0.8.3.crate
memark commented 1 year ago

AFAIK, cargo install can only put piles in .cargo/bin, so I wouldn't expect the completions to be working from there. I would suggest using homebrew for installation, which installs the completions automatically.

alecandido commented 1 year ago

Not on MacOS, and some Linux packages are ages behind latest release.

memark commented 1 year ago

Actually it works perfectly for me on latest MacOS.

ajeetdsouza commented 1 year ago

That's exactly right, cargo install cannot install completions and manpages. @AleCandido I would suggest using the curl-based installer listed in the README on Linux systems:

curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
alecandido commented 1 year ago

@AleCandido I would suggest using the curl-based installer listed in the README on Linux systems:

This is a reasonable alternative. But how would it update?

ajeetdsouza commented 1 year ago

I think your only options are to either rerun the curl script, or to use a different package manager (Nix / Linuxbrew comes to mind). Unfortunately, a lot of Linux distributions tend to lag behind in terms of updates (Debian / Ubuntu derivatives are still on 0.4.3!) but there's not much I can do about that.

I myself tend to use Fedora / Arch for exactly this reason. The Releases page does include DEBs for Ubuntu, but unfortunately creating a PPA is not quite as simple.

alecandido commented 1 year ago

I agree, but on the other hand I personally decided not to take the burden of maintaining also system utils (Arch is mostly fine, but sometimes things break while rolling), that's why I'm on a Debian-based distro (and this is exactly what I was mentioning with ages behind above).

On the other hand, I do not want to lag behind with some other utilities, so I usually install with languages package managers, since it is much simpler for authors to release on the languages' registries (like crates.io for Rust). I see that they have limitations, but maybe there are clever ways to overcome them.

The truly useful advice is installing with Nix, I'm considering it. But it is a further source, so I'm a bit reluctant...

However, in this case I do not need the completion to be installed by the package, I just need a command to output the completion script for ZSH, and then I'm installing it myself with something like:

if [ ! -f "$COMPLETIONS/_mycli" ]; then
    mycli completion zsh >$COMPLETIONS/_mycli
fi

with the drawback that I have to manually delete the file to trigger completion update (but I'd be willing to accept this).