Created
March 5, 2015 12:38
-
-
Save spadgos/bb073262d16662d001f4 to your computer and use it in GitHub Desktop.
npm <tab>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ npm ###-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 type 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 type compdef &>/dev/null; then | |
_npm_completion() { | |
si=$IFS | |
compadd -- $(COMP_CWORD=$((CURRENT-1)) \ | |
COMP_LINE=$BUFFER \ | |
COMP_POINT=0 \ | |
npm completion -- "${words[@]}" \ | |
2>/dev/null) | |
IFS=$si | |
} | |
compdef _npm_completion npm | |
elif type 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-### | |
npm 103734 | |
\> COMP_LINE=\"\$line\" line | |
\>\> COMP_POINT=0 -ln | |
\|\| COMP_POINT=\"\$COMP_POINT\" local | |
-- COMP_POINT=\"\$point\" maybe: | |
\(\) COMPREPLY=\(\$\(COMP_CWORD=\"\$COMP_CWORD\" npm | |
\{ COMP_WORDBREAKS _npm_completion | |
\} COMP_WORDBREAKS=\$\{COMP_WORDBREAKS/=/\} _npm_completion\(\) | |
\$\? COMP_WORDBREAKS=\$\{COMP_WORDBREAKS/@/\} \(or | |
\\ \"\$\{COMP_WORDS\[@\]\}\" Or, | |
\# cword point | |
2\>/dev/null\) cword-=1 read | |
2\>/dev/null\)\) \&\>/dev/null\; reply=\(\$\(COMP_CWORD=\"\$cword\" | |
-Ac elif return | |
\~/.bashrc \#\#\#-end-npm-completion-\#\#\# script | |
\#\#\#-begin-npm-completion-\#\#\# export si | |
-cn -F si=\"\$IFS\" | |
command fi si=\$IFS | |
compadd if then | |
compctl IFS=\$\'\\n\' type | |
\$\(COMP_CWORD=\$\(\(CURRENT-1\)\) IFS=\"\$si\" /usr/local/etc/bash_completion.d/npm | |
compdef IFS=\$si words | |
complete Installation: \"\$\{words\[@\]\}\" | |
completion -K \~/.zshrc\) | |
COMP_LINE=\$BUFFER -l | |
COMP_LINE=\"\$COMP_LINE\" let |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment