# HG changeset patch # User Oleksandr Gavenko # Date 1631708534 -10800 # Node ID d9cb7673d29cd3cdceff5a988053aad0b246f031 # Parent 57fda390e91c8730f619ad05035fe15e49bd7d48 Bash completion for npx. diff -r 57fda390e91c -r d9cb7673d29c .bash_completion.d/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