_bower
1648 bytes
1
2
3# Credits to npm's awesome completion utility.
4#
5# Bower completion script, based on npm completion script.
6
7###-begin-bower-completion-###
8#
9# Installation: bower completion >> ~/.bashrc (or ~/.zshrc)
10# Or, maybe: bower completion > /usr/local/etc/bash_completion.d/bower
11#
12
13COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
14COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
15export COMP_WORDBREAKS
16
17if type complete &>/dev/null; then
18 _bower_completion () {
19 local si="$IFS"
20 IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
21 COMP_LINE="$COMP_LINE" \
22 COMP_POINT="$COMP_POINT" \
23 bower completion -- "${COMP_WORDS[@]}" \
24 2>/dev/null)) || return $?
25 IFS="$si"
26 }
27 complete -F _bower_completion bower
28elif type compdef &>/dev/null; then
29 _bower_completion() {
30 si=$IFS
31 compadd -- $(COMP_CWORD=$((CURRENT-1)) \
32 COMP_LINE=$BUFFER \
33 COMP_POINT=0 \
34 bower completion -- "${words[@]}" \
35 2>/dev/null)
36 IFS=$si
37 }
38 compdef _bower_completion bower
39elif type compctl &>/dev/null; then
40 _bower_completion () {
41 local cword line point words si
42 read -Ac words
43 read -cn cword
44 let cword-=1
45 read -l line
46 read -ln point
47 si="$IFS"
48 IFS=$'\n' reply=($(COMP_CWORD="$cword" \
49 COMP_LINE="$line" \
50 COMP_POINT="$point" \
51 bower completion -- "${words[@]}" \
52 2>/dev/null)) || return $?
53 IFS="$si"
54 }
55 compctl -K _bower_completion bower
56fi
57###-end-bower-completion-###
58