.bash_completion.d/npx
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 12 Jun 2022 19:01:39 +0300
changeset 1001 b4df956c3d52
parent 992 d9cb7673d29c
permissions -rw-r--r--
Added Bash completion for winget.

# -*- 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