Skip to content

Instantly share code, notes, and snippets.

@ianpurvis
Forked from gibatronic/README.md
Last active September 11, 2019 14:08
Show Gist options
  • Save ianpurvis/1bbe017804cf4d56a7d431caccb654ca to your computer and use it in GitHub Desktop.
Save ianpurvis/1bbe017804cf4d56a7d431caccb654ca to your computer and use it in GitHub Desktop.
Tab completion for the npx command

complete_npx

Tab completion for the npx command

Usage

Save complete_npx in your home folder and then source it on your .bash_profile with:

. ~/complete_npx
# Based on gibatronic complete_npx
# https://gist.github.com/gibatronic/44073260ffdcbd122e9520756c8e35a1
complete_npx() {
local CURR_ARG
local FILES=$(find $(npm bin) -perm +111 -type f -or -type l -print0 | xargs -0 basename)
CURR_ARG=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${FILES[@]}" -- $CURR_ARG ) );
}
complete -F complete_npx npx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment