Bash completion for npx.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.bash_completion.d/npx Wed Sep 15 15:22:14 2021 +0300
@@ -0,0 +1,18 @@
+# -*- mode: sh; sh-shell-file: bash -*-
+
+_npx() {
+ local dir=$(pwd -P)
+ while [[ -n "$dir" ]]; do
+ if [[ ! -d $dir/node_modules/.bin ]]; then
+ dir=${dir%/*}
+ continue
+ fi
+ local execs=( `cd $dir/node_modules/.bin; find -L . -type f -executable` )
+ execs=( ${execs[@]/#.\//} )
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ COMPREPLY=( $(compgen -W "${execs[*]}" -- "$cur" ) )
+ break
+ done
+}
+
+complete -F _npx npx