mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
#!/bin/bash
|
|
###-begin-npm-completion-###
|
|
#
|
|
# npm command completion script
|
|
#
|
|
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
|
|
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
|
|
#
|
|
|
|
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
|
|
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
|
|
export COMP_WORDBREAKS
|
|
|
|
if complete &>/dev/null; then
|
|
_npm_completion () {
|
|
local si="$IFS"
|
|
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
|
COMP_LINE="$COMP_LINE" \
|
|
COMP_POINT="$COMP_POINT" \
|
|
npm completion -- "${COMP_WORDS[@]}" \
|
|
2>/dev/null)) || return $?
|
|
IFS="$si"
|
|
}
|
|
complete -F _npm_completion npm
|
|
elif compctl &>/dev/null; then
|
|
_npm_completion () {
|
|
local cword line point words si
|
|
read -Ac words
|
|
read -cn cword
|
|
let cword-=1
|
|
read -l line
|
|
read -ln point
|
|
si="$IFS"
|
|
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
|
|
COMP_LINE="$line" \
|
|
COMP_POINT="$point" \
|
|
npm completion -- "${words[@]}" \
|
|
2>/dev/null)) || return $?
|
|
IFS="$si"
|
|
}
|
|
compctl -K _npm_completion npm
|
|
fi
|
|
###-end-npm-completion-###
|
|
|