zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

shell tab-completion #5

Open zkat opened 7 years ago

zkat commented 7 years ago

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.

pi0 commented 7 years ago

@zkat Do you mean using auto completion functionality for shells like Bash or Zsh ? :))

zkat commented 7 years ago

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

egourlao commented 7 years ago

I got it running on a few shells:

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?

zkat commented 7 years ago

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

LitoMore commented 7 years ago

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 .

kaleb commented 7 years ago

I can start the completions for fish.

zkat commented 7 years ago

@kaleb awesome!

Haroenv commented 7 years ago

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

gibatronic commented 6 years ago

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.

alvaropinot commented 6 years ago

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

Haroenv commented 6 years ago

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)

zkat commented 6 years ago

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

Haroenv commented 6 years ago

Sure, sorry for suggesting :)