Adding autocomplete to npm install
Every time I have to type this without autocomplete I get really annoyed:
$ npm install some-really-really-long-package-name
I spent a few hours last night and figured it out.
Solutions below are for bash / zsh only (not Windows, sorry).
If you don’t use npm autocompletion yet, add this snippet to your ~/.bashrc:
If you use zsh, add this to ~/.zshrc.
If you already use npm autocompletion, replace your version with this one: https://gist.github.com/jamischarles/1669accda0f057df1769c6c0e932827f
How it works
We run `ls ~/.npm` and pass all the results as options to bash/zsh autocompletion for the `npm install` command. ~/.npm is the location of the npm cache. This should contain any packages you’ve installed at some point (Not all of npm.).
Questions, comments, feedback? I’m a bash newb, so any improvements are welcome.