Skip to content
This repository

Bower plugin #1614

Merged
merged 5 commits into from about 1 year ago

2 participants

Martin Miklós Robby Russell
Martin Miklós

Hi!

I've noticed, that a few folks are using this plugin, so I thought it would be nice to make it available from the original repo.

Here is the description:

Bower is a package manager for the web.
This plugin provides some aliases and completitions for this great tool.

Aliases

bi: installs a package (bower install)
bl: lists installed packages (bower list)
bs: searches for packages (bower search)

Completition

It completes the basic commands for bower. It uses the bower help command to achieve this, not a burned-in list of commands.
It also provides completition for bower install, uses the output of bower search. It takes a few seconds for the first time (in the session), but then the output of bower search is cached, so things then speed up a lot.

Example

# to install jquery for example
bi jq<TAB>
Robby Russell
Owner

Thanks, can you add some details to our wiki plugins page for this?

Robby Russell robbyrussell merged commit eabf51e into from March 26, 2013
Robby Russell robbyrussell closed this March 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 38  plugins/bower/bower.plugin.zsh
38  plugins/bower/bower.plugin.zsh
... ...
@@ -0,0 +1,38 @@
  1
+alias bi="bower install"
  2
+alias bl="bower list"
  3
+alias bs="bower search"
  4
+
  5
+bower_package_list=''
  6
+
  7
+_bower ()
  8
+{
  9
+	local curcontext="$curcontext" state line
  10
+	typeset -A opt_args
  11
+
  12
+	_arguments -C \
  13
+		':command:->command' \
  14
+		'*::options:->options'
  15
+
  16
+	case $state in
  17
+		(command)
  18
+
  19
+			local -a subcommands
  20
+			subcommands=(${=$(bower help | grep help | sed -e 's/,//g')})
  21
+			_describe -t commands 'bower' subcommands
  22
+		;;
  23
+
  24
+		(options)
  25
+			case $line[1] in
  26
+
  27
+				(install)
  28
+				    if [ -z "$bower_package_list" ];then
  29
+                    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")
  30
+                fi
  31
+				    compadd "$@" $(echo $bower_package_list)
  32
+                ;;
  33
+			esac
  34
+		;;
  35
+	esac
  36
+}
  37
+
  38
+compdef _bower bower
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.