zoxide icon indicating copy to clipboard operation
zoxide copied to clipboard

Clap completion not installed

Open alecandido opened this issue 2 years ago • 9 comments

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

alecandido avatar Nov 13 '22 12:11 alecandido

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?

memark avatar Dec 11 '22 20:12 memark

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

alecandido avatar Dec 12 '22 00:12 alecandido

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.

memark avatar Dec 13 '22 14:12 memark

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

alecandido avatar Dec 13 '22 19:12 alecandido

Actually it works perfectly for me on latest MacOS.

memark avatar Dec 13 '22 19:12 memark

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

ajeetdsouza avatar Dec 13 '22 19:12 ajeetdsouza

@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?

alecandido avatar Dec 13 '22 20:12 alecandido

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.

ajeetdsouza avatar Dec 13 '22 22:12 ajeetdsouza

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).

alecandido avatar Dec 13 '22 22:12 alecandido