1 alias angular='frontend angular'
2 alias angularjs='frontend angularjs'
3 alias bem='frontend bem'
4 alias bootsnipp='frontend bootsnipp'
5 alias bundlephobia='frontend bundlephobia'
6 alias caniuse='frontend caniuse'
7 alias codepen='frontend codepen'
8 alias compassdoc='frontend compassdoc'
9 alias cssflow='frontend cssflow'
10 alias dartlang='frontend dartlang'
11 alias emberjs='frontend emberjs'
12 alias flowtype='frontend flowtype'
13 alias fontello='frontend fontello'
14 alias github='frontend github'
15 alias html5please='frontend html5please'
16 alias jestjs='frontend jestjs'
17 alias jquery='frontend jquery'
18 alias lodash='frontend lodash'
19 alias mdn='frontend mdn'
20 alias nodejs='frontend nodejs'
21 alias npmjs='frontend npmjs'
22 alias packagephobia='frontend packagephobia'
23 alias qunit='frontend qunit'
24 alias reactjs='frontend reactjs'
25 alias smacss='frontend smacss'
26 alias stackoverflow='frontend stackoverflow'
27 alias typescript='frontend typescript'
28 alias unheap='frontend unheap'
29 alias vuejs='frontend vuejs'
31 function _frontend_fallback() {
32 case "$FRONTEND_SEARCH_FALLBACK" in
33 duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;;
34 *) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;;
41 # define search context URLS
44 angular 'https://angular.io/?search='
45 angularjs $(_frontend_fallback 'angularjs.org')
46 bem $(_frontend_fallback 'bem.info')
47 bootsnipp 'https://bootsnipp.com/search?q='
48 bundlephobia 'https://bundlephobia.com/result?p='
49 caniuse 'https://caniuse.com/#search='
50 codepen 'https://codepen.io/search/pens?q='
51 compassdoc 'http://compass-style.org/search?q='
52 cssflow 'http://www.cssflow.com/search?q='
53 dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
54 emberjs $(_frontend_fallback 'emberjs.com/')
55 flowtype $(_frontend_fallback 'flow.org/en/docs/')
56 fontello 'http://fontello.com/#search='
57 github 'https://github.com/search?q='
58 html5please 'https://html5please.com/#'
59 jestjs $(_frontend_fallback 'jestjs.io')
60 jquery 'https://api.jquery.com/?s='
61 lodash 'https://devdocs.io/lodash/index#'
62 mdn 'https://developer.mozilla.org/search?q='
63 nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
64 npmjs 'https://www.npmjs.com/search?q='
65 packagephobia 'https://packagephobia.now.sh/result?p='
66 qunit 'https://api.qunitjs.com/?s='
67 reactjs $(_frontend_fallback 'reactjs.org/')
68 smacss $(_frontend_fallback 'smacss.com')
69 stackoverflow 'https://stackoverflow.com/search?q='
70 typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
71 unheap 'http://www.unheap.com/?s='
72 vuejs $(_frontend_fallback 'vuejs.org')
75 # show help for command list
76 if [[ $# -lt 2 ]]; then
77 print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
79 print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
80 print -P "and %Ucontext%u is one of the following:"
82 print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
83 print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
84 print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
86 print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
91 # check whether the search context is supported
92 if [[ -z "$urls[$1]" ]]; then
93 echo "Search context \"$1\" currently not supported."
95 echo "Valid contexts are:"
97 echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
98 echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
99 echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
105 # join arguments passed with '%20', then append to search context URL
106 url="${urls[$1]}$(omz_urlencode -P ${@[2,-1]})"
108 echo "Opening $url ..."