summaryrefslogtreecommitdiff
path: root/plugins/bower
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/bower')
-rwxr-xr-xplugins/bower/_bower58
-rw-r--r--plugins/bower/bower.plugin.zsh38
2 files changed, 96 insertions, 0 deletions
diff --git a/plugins/bower/_bower b/plugins/bower/_bower
new file mode 100755
index 000000000..ae0ca4a4e
--- /dev/null
+++ b/plugins/bower/_bower
@@ -0,0 +1,58 @@
+
+
+# Credits to npm's awesome completion utility.
+#
+# Bower completion script, based on npm completion script.
+
+###-begin-bower-completion-###
+#
+# Installation: bower completion >> ~/.bashrc (or ~/.zshrc)
+# Or, maybe: bower completion > /usr/local/etc/bash_completion.d/bower
+#
+
+COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
+COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
+export COMP_WORDBREAKS
+
+if type complete &>/dev/null; then
+ _bower_completion () {
+ local si="$IFS"
+ IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
+ COMP_LINE="$COMP_LINE" \
+ COMP_POINT="$COMP_POINT" \
+ bower completion -- "${COMP_WORDS[@]}" \
+ 2>/dev/null)) || return $?
+ IFS="$si"
+ }
+ complete -F _bower_completion bower
+elif type compdef &>/dev/null; then
+ _bower_completion() {
+ si=$IFS
+ compadd -- $(COMP_CWORD=$((CURRENT-1)) \
+ COMP_LINE=$BUFFER \
+ COMP_POINT=0 \
+ bower completion -- "${words[@]}" \
+ 2>/dev/null)
+ IFS=$si
+ }
+ compdef _bower_completion bower
+elif type compctl &>/dev/null; then
+ _bower_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" \
+ bower completion -- "${words[@]}" \
+ 2>/dev/null)) || return $?
+ IFS="$si"
+ }
+ compctl -K _bower_completion bower
+fi
+###-end-bower-completion-###
+
diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh
new file mode 100644
index 000000000..ed9c04840
--- /dev/null
+++ b/plugins/bower/bower.plugin.zsh
@@ -0,0 +1,38 @@
+alias bi="bower install"
+alias bl="bower list"
+alias bs="bower search"
+
+bower_package_list=''
+
+_bower ()
+{
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments -C \
+ ':command:->command' \
+ '*::options:->options'
+
+ case $state in
+ (command)
+
+ local -a subcommands
+ subcommands=(${=$(bower help | grep help | sed -e 's/,//g')})
+ _describe -t commands 'bower' subcommands
+ ;;
+
+ (options)
+ case $line[1] in
+
+ (install)
+ if [ -z "$bower_package_list" ];then
+ bower_package_list=$(bower search | awk 'NR > 2' | cut -d '-' -f 2 | cut -d ' ' -f 2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
+ fi
+ compadd "$@" $(echo $bower_package_list)
+ ;;
+ esac
+ ;;
+ esac
+}
+
+compdef _bower bower