]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/bower/bower.plugin.zsh
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / bower / bower.plugin.zsh
1 alias bi="bower install"
2 alias bisd="bower install --save-dev"
3 alias bis="bower install --save"
4 alias bl="bower list"
5 alias bs="bower search"
6
7 _bower_installed_packages () {
8     bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//')
9 }
10 _bower ()
11 {
12     local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production
13     local expl
14     typeset -A opt_args
15
16     _no_color=('--no-color[Do not print colors (available in all commands)]')
17
18     _dopts=(
19         '(--save)--save[Save installed packages into the project"s bower.json dependencies]'
20         '(--force)--force[Force fetching remote resources even if a local copy exists on disk]'
21     )
22
23     _save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
24
25     _force_latest=('(--force-latest)--force-latest[Force latest version on conflict]')
26
27     _production=('(--production)--production[Do not install project devDependencies]')
28
29     _1st_arguments=(
30     'cache-clean:Clean the Bower cache, or the specified package caches' \
31     'help:Display help information about Bower' \
32     'info:Version info and description of a particular package' \
33     'init:Interactively create a bower.json file' \
34     'install:Install a package locally' \
35     'link:Symlink a package folder' \
36     'lookup:Look up a package URL by name' \
37     'register:Register a package' \
38     'search:Search for a package by name' \
39     'uninstall:Remove a package' \
40     'update:Update a package' \
41     {ls,list}:'[List all installed packages]'
42     )
43     _arguments \
44     $_no_color \
45     '*:: :->subcmds' && return 0
46
47     if (( CURRENT == 1 )); then
48         _describe -t commands "bower subcommand" _1st_arguments
49         return
50     fi
51
52     case "$words[1]" in
53         install)
54         _arguments \
55         $_dopts \
56         $_save_dev \
57         $_force_latest \
58         $_no_color \
59         $_production
60         ;;
61         update)
62         _arguments \
63         $_dopts \
64         $_no_color \
65         $_force_latest
66         _bower_installed_packages
67         compadd "$@" $(echo $bower_package_list)
68         ;;
69         uninstall)
70         _arguments \
71         $_no_color \
72         $_dopts
73         _bower_installed_packages
74         compadd "$@" $(echo $bower_package_list)
75         ;;
76         *)
77         _arguments \
78         $_no_color \
79         ;;
80     esac
81
82 }
83
84 compdef _bower bower