Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh & bash completions #171

Closed
gillchristian opened this issue Nov 21, 2019 · 6 comments
Closed

zsh & bash completions #171

gillchristian opened this issue Nov 21, 2019 · 6 comments

Comments

@gillchristian
Copy link

I see there's already some work in progress for adding fish completions (#105).

Would you be interested to add bash and zsh ones?

A friend of mine is working on a way to generate completions (completely). At the moment it only supports a JSON declaration as the input. Eventually there will be a DSL to write them and/or some way to generate completions from the --help command.

I can write the JSON declaration and then generate them and open a PR or the other option is to have the JSON declarations in the repo and run it in a build step.

Also, great project! Thanks for working on this! 🎉

@Schniz
Copy link
Owner

Schniz commented Oct 14, 2020

The new version (implemented in Rust) is shipped with completions:

fnm completions --shell {bash,zsh,fish,powershell}

will produce shell completions

@Schniz Schniz closed this as completed Oct 14, 2020
@anan44
Copy link

anan44 commented Nov 4, 2020

I have a problem with the zsh completions. There is no instructions what to do with the output provided by fnm. Apparently for fish it works out of the box, but this does not seem to be the case with zsh.

@Schniz
Copy link
Owner

Schniz commented Nov 4, 2020

Hi @anan44! What's up 😄

I'm not entirely sure how to do with zsh completions, but I know that homebrew installs them (verified that) and I know that it works for me on my machine, and this is how I did it locally:

fnm completions --shell=zsh > ~/.zfunc/_fnm

because I have the following in my .zshrc:

fpath+=~/.zfunc
compinit

I guess it says:

  • add the ~/.zfunc dir to the functions dir
  • initialize completions

Can you try that to install completions?

@anan44
Copy link

anan44 commented Nov 4, 2020

Hi @Schniz!

First of all huge hats off for faster that speed of light response!

I tried your instructions and it works like a charm! Thanks mate!

@batbrain9392
Copy link

batbrain9392 commented Jan 3, 2023

I'm using antigen and followed these steps:

  1. Added zsh-completions antigen plugin in ~/.zshrc
  2. Then ran fnm completions --shell=zsh > ~/.antigen/bundles/zsh-users/zsh-completions/src/_fnm as given here.

Works for me.

@alexilyaev
Copy link

alexilyaev commented Mar 23, 2023

Installing latest fnm (using zsh) adds the completions automatically to /opt/homebrew/share/zsh/site-functions (mentioned in the notes after installation).

So adding this to .zshrc is enough:

fpath+="/opt/homebrew/share/zsh/site-functions"

autoload -Uz compinit
compinit

I wish this was in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants