1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-04 19:50:08 +00:00
ohmyzsh/plugins/frontend-search/frontend-search.plugin.zsh

106 lines
4.3 KiB
Bash
Raw Normal View History

2019-05-06 17:09:51 +00:00
alias angular='frontend angular'
2015-08-31 17:12:05 +00:00
alias angularjs='frontend angularjs'
alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
alias bundlephobia='frontend bundlephobia'
2015-08-31 17:12:05 +00:00
alias caniuse='frontend caniuse'
alias codepen='frontend codepen'
2016-02-21 13:09:27 +00:00
alias compassdoc='frontend compassdoc'
2015-08-31 17:12:05 +00:00
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
alias flowtype='frontend flowtype'
2015-08-31 17:12:05 +00:00
alias fontello='frontend fontello'
alias github='frontend github'
2015-08-31 17:12:05 +00:00
alias html5please='frontend html5please'
alias jestjs='frontend jestjs'
2015-08-31 17:12:05 +00:00
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
alias nodejs='frontend nodejs'
2015-08-31 17:12:05 +00:00
alias npmjs='frontend npmjs'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
alias typescript='frontend typescript'
2015-08-31 17:12:05 +00:00
alias unheap='frontend unheap'
alias vuejs='frontend vuejs'
2015-08-31 17:12:05 +00:00
2014-06-20 02:27:40 +00:00
function frontend() {
emulate -L zsh
# define search context URLS
typeset -A urls
urls=(
angular 'https://angular.io/?search='
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search='
codepen 'https://codepen.io/search?q='
2016-02-21 13:09:27 +00:00
compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q='
flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q='
fontello 'http://fontello.com/#search='
github 'https://github.com/search?q='
html5please 'https://html5please.com/#'
jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q='
jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q='
nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q='
npmjs 'https://www.npmjs.com/search?q='
qunit 'https://api.qunitjs.com/?s='
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
stackoverflow 'https://stackoverflow.com/search?q='
typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q='
unheap 'http://www.unheap.com/?s='
vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q='
)
2014-06-20 02:27:40 +00:00
# show help for command list
if [[ $# -lt 2 ]]
then
print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
2019-05-04 20:42:06 +00:00
print -P ""
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
print -P "and %Ucontext%u is one of the following:"
print -P ""
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
print -P ""
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
print -P ""
return 1
fi
# check whether the search context is supported
if [[ -z "$urls[$1]" ]]
2014-06-20 02:27:40 +00:00
then
echo "Search context \"$1\" currently not supported."
echo ""
echo "Valid contexts are:"
echo ""
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
2014-06-20 02:27:40 +00:00
echo ""
return 1
fi
# build search url:
2019-05-06 17:09:51 +00:00
# join arguments passed with '%20', then append to search context URL
# TODO substitute for proper urlencode method
2019-05-04 20:42:06 +00:00
url="${urls[$1]}${(j:%20:)@[2,-1]}"
2014-06-20 02:27:40 +00:00
echo "Opening $url ..."
2014-06-20 02:27:40 +00:00
open_command "$url"
2014-06-20 02:27:40 +00:00
}