9c08641d7c2aae0c82fa5ad91f94c67b70115ba5
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
2index b8e96ea4a36770a7731b4c20e30221a43594bc7a..d0bc5589f742e2dd3081242f2811b69d0571bff4 100644
3--- a/plugins/frontend-search/README.md
4+++ b/plugins/frontend-search/README.md
5@@ -1,76 +1,60 @@
6-## Rationale ##
7+## Introduction ##
8
9-> Searches for your Frontend contents more easier
10+> Searches for your frontend web development made easier
11
12
13-## Instalation ##
14+## Installation ##
15
16+Open your `~/.zshrc` file and enable the `frontend-search` plugin:
17
18-Open your `.zshrc` file and load `frontend-search` plugin
19+```zsh
20+
21+plugins=( ... frontend-search)
22
23-```bash
24-...
25-plugins=( <your-plugins-list>... frontend-search)
26-...
27 ```
28
29
30-## Commands ##
31-
32-All command searches are accept only in format
33-
34-* `frontend <search-content> <search-term>`
35-
36-The search content are
37-
38-* `jquery <api.jquery.com>`
39-* `mdn <developer.mozilla.org>`
40-* `compass <compass-style.org>`
41-* `html5please <html5please.com>`
42-* `caniuse <caniuse.com>`
43-* `aurajs <aurajs.com>`
44-* `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>`
45-* `lodash <search>`
46-* `qunit <api.qunitjs.com>`
47-* `fontello <fontello.com>`
48-* `bootsnipp <bootsnipp.com>`
49-* `cssflow <cssflow.com>`
50-* `codepen <codepen.io>`
51-* `unheap <www.unheap.com>`
52-* `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>`
53-* `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>`
54-* `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>`
55-* `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
56-* `emberjs <emberjs.com>`
57-* `stackoverflow <stackoverflow.com>`
58-* `npmjs <npmjs.com>`
59-
60-
61-## Aliases ##
62-
63-There are a few aliases presented as well:
64-
65-* `jquery` A shorthand for `frontend jquery`
66-* `mdn` A shorthand for `frontend mdn`
67-* `compass` A shorthand for `frontend compass`
68-* `html5please` A shorthand for `frontend html5please`
69-* `caniuse` A shorthand for `frontend caniuse`
70-* `aurajs` A shorthand for `frontend aurajs`
71-* `dartlang` A shorthand for `frontend dartlang`
72-* `lodash` A shorthand for `frontend lodash`
73-* `qunit` A shorthand for `frontend qunit`
74-* `fontello` A shorthand for `frontend fontello`
75-* `bootsnipp` A shorthand for `frontend bootsnipp`
76-* `cssflow` A shorthand for `frontend cssflow`
77-* `codepen` A shorthand for `frontend codepen`
78-* `unheap` A shorthand for `frontend unheap`
79-* `bem` A shorthand for `frontend bem`
80-* `smacss` A shorthand for `frontend smacss`
81-* `angularjs` A shorthand for `frontend angularjs`
82-* `reactjs` A shorthand for `frontend reactjs`
83-* `emberjs` A shorthand for `frontend emberjs`
84-* `stackoverflow` A shorthand for `frontend stackoverflow`
85-* `npmjs` A shorthand for `frontend npmjs`
86+## Usage ##
87+
88+You can use the frontend-search plugin in these two forms:
89+
90+* `frontend <context> <term> [more terms if you want]`
91+* `<context> <term> [more terms if you want]`
92+
93+For example, these two are equivalent:
94+
95+```zsh
96+$ frontend angularjs dependency injection
97+$ angularjs dependency injection
98+```
99+
100+Available search contexts are:
101+
102+| context | URL |
103+|---------------|--------------------------------------------------------------------------|
104+| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
105diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
106index e47735a60fe7fc2ea455f4e95ee236df8f4f24de..2fd5416b3c032aaab73f1ea780aa717881ddb680 100644
107--- a/plugins/frontend-search/frontend-search.plugin.zsh
108+++ b/plugins/frontend-search/frontend-search.plugin.zsh
109@@ -1,155 +1,91 @@
110-# frontend from terminal
111+alias angularjs='frontend angularjs'
112+alias aurajs='frontend aurajs'
113+alias bem='frontend bem'
114+alias bootsnipp='frontend bootsnipp'
115+alias caniuse='frontend caniuse'
116+alias codepen='frontend codepen'
117+alias compass='frontend compass'
118+alias cssflow='frontend cssflow'
119+alias dartlang='frontend dartlang'
120+alias emberjs='frontend emberjs'
121+alias fontello='frontend fontello'
122+alias html5please='frontend html5please'
123+alias jquery='frontend jquery'
124+alias lodash='frontend lodash'
125+alias mdn='frontend mdn'
126+alias npmjs='frontend npmjs'
127+alias qunit='frontend qunit'
128+alias reactjs='frontend reactjs'
129+alias smacss='frontend smacss'
130+alias stackoverflow='frontend stackoverflow'
131+alias unheap='frontend unheap'
132
133 function frontend() {
134-
135- # no keyword provided, simply show how call methods
136- if [[ $# -le 1 ]]; then
137- echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
138- return 1
139+ emulate -L zsh
140+
141+ # define search context URLS
142+ typeset -A urls
143+ urls=(
144+ angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
145+ aurajs 'http://aurajs.com/api/#stq='
146+ bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
147+ bootsnipp 'http://bootsnipp.com/search?q='
148+ caniuse 'http://caniuse.com/#search='
149+ codepen 'http://codepen.io/search?q='
150+ compass 'http://compass-style.org/search?q='
151+ cssflow 'http://www.cssflow.com/search?q='
152+ dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
153+ emberjs 'http://emberjs.com/api/#stp=1&stq='
154+ fontello 'http://fontello.com/#search='
155+ html5please 'http://html5please.com/#'
156+ jquery 'https://api.jquery.com/?s='
157+ lodash 'https://devdocs.io/lodash/index#'
158+ mdn 'https://developer.mozilla.org/search?q='
159+ npmjs 'https://www.npmjs.com/search?q='
160+ qunit 'https://api.qunitjs.com/?s='
161+ reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
162+ smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
163+ stackoverflow 'http://stackoverflow.com/search?q='
164+ unheap 'http://www.unheap.com/?s='
165+ )
166+
167+ # show help for command list
168+ if [[ $# -lt 2 ]]
169+ then
170+ print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
171+ print -P ""
172+ print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
173+ print -P "and %Ucontext%u is one of the following:"
174+ print -P ""
175+ print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow,"
176+ print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
177+ print -P " qunit, reactjs, smacss, stackoverflow, unheap"
178+ print -P ""
179+ print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
180+ print -P ""
181+ return 1
182 fi
183
184- # check whether the search engine is supported
185- if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]];
186+ # check whether the search context is supported
187+ if [[ -z "$urls[$1]" ]]
188 then
189- echo "Search valid search content $1 not supported."
190- echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
191- echo "* jquery"
192- echo "* mdn"
193- echo "* compass"
194- echo "* html5please"
195- echo "* caniuse"
196- echo "* aurajs"
197- echo "* dartlang"
198- echo "* lodash"
199- echo "* qunit"
200- echo "* fontello"
201- echo "* bootsnipp"
202- echo "* cssflow"
203- echo "* codepen"
204- echo "* unheap"
205- echo "* bem"
206- echo "* smacss"
207- echo "* angularjs"
208- echo "* reactjs"