Open zkat opened 7 years ago
@zkat Do you mean using auto completion functionality for shells like Bash or Zsh ? :))
@pi0 I want to do npx stan<TAB> -> npx standard
, if standard
is in the $PATH
. It's not really necessary to auto-complete for remote package names (yet?), but having the basic thing working would be nice.
I got it running on a few shells:
bash
, it requires adding complete -A command npx
to your ~/.bashrc
file.zsh
, it requires adding compctl -m npx
to your ~/.zshrc
file.Issue with this command though is that it returns all the commands in $PATH
, not just those installed with npm
. I didn't get it running on fish
, but if there are some enthusiasts here, there's a complete
function in fish
- that has a man
page.
Also, it's possible for bash
and zsh
to program the shell to call a shell function to get the completion list - so depending on the shell, it could be possible for users to auto-complete for remote package names.
What do you think should be the approach to let users know about this, add it in the README?
@dotpy3 I think having something for folks to get started is a great idea. We can deal with remote-pkg autocompletion later, since that is a little harder (the search space is enormous and I need to see what the state-of-the-art is for the registry rn)
I would add a section to the README
that describes how to set up auto completion.
I want to do npx stan<TAB> -> npx standard
, if standard
is in the ./node_modules/.bin/
but not in the $PATH
.
We need a shell plugin like this one -> robbyrussell/oh-my-zsh#1614 .
I can start the completions for fish.
@kaleb awesome!
When we get there later, there's an Algolia index with all package information that could be used, this should be fast enough for auto-completion. I can provide more information if wanted
I've made a bash script that might put some light on the matter: https://gist.github.com/gibatronic/44073260ffdcbd122e9520756c8e35a1
When typing npx <tab>
it is going to suggest any executable inside the ./node_modules/.bin/
folder.
Any updates about the remote search or the actual completion script 😃? I just though about doing this 😅
@Haroenv can you please provide more info about that Algolia index? 😊
All info for that should be at https://github.com/Algolia/npm-search, an example usage is https://github.com/yarnpkg/website or Emma CLI. Feel free to ask more info in email (haroen@algolia.com)
We don't use Algolia and we won't be. We have our own completion endpoint but it needs to be scaled/load-tested before it can be made public (and thus the CLI can use it). We actually don't like Algolia's results very much (and yes, I'm leaving it at that).
Sure, sorry for suggesting :)
jfc please just give us completion support, at least for existing binaries in the
$PATH
or in~/.npm/_npx/bin
. There's gotta be something nice and easy the cool kids use these days to set up easy completion stuff.Do you wanna pick this up? I'd love the help.