npm-tabs

1.0.2 • Public • Published

npm-tabs

An autocompletion shell script that autocompletes the commands based on the scripts declared in the package.json file.

Dependencies required

  • Jq
  • Terminal that runs shell script (Support for windows under development)

Running

  • After installing the package , use the following command in the root folder of your application
cd node_modules/npm-tabs ; tr -cd '[:alnum:][:blank:][:punct:]\n' < npm-tabs.sh > npm-tabs-min.sh ; source npm-tabs-min.sh
  • It should automatically install the necessary dependencies

If it says 'source' is not recognized as an internal or external command. Try running the command from a bash terminal

cygWin - https://www.cygwin.com/
git - https://git-scm.com/download/win

  • Now while typing npm run (default command to run npm scripts) press tab to show the list of suggested commands

Snippets

Get the npm script names as an array

sample=`cat package.json`
arr=()
arr=($(echo "${sample}" | jq -r ' .scripts |keys | join(" ")'))

Autocomplete based on the array

_UseGetOpt-2 ()
{
  local cur
  cur=${COMP_WORDS[COMP_CWORD]}
  COMPREPLY=( $( compgen -W '${arr[*]}' $cur))
  case "$cur" in
    -*)
    COMPREPLY=( $( compgen -W '-a -d -f -l -t -h --aoption --debug \
                               --file --log --test --help --' -- $cur ) );
  esac
  return 0
}
 
complete -F _UseGetOpt-2 -o filenames npm run

Output

Package Sidebar

Install

npm i npm-tabs

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

4.13 kB

Total Files

3

Last publish

Collaborators

  • dhiraj3194