summaryrefslogtreecommitdiff
path: root/plugins/frontend-search/frontend-search.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/frontend-search/frontend-search.plugin.zsh')
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh65
1 files changed, 45 insertions, 20 deletions
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index 3fd49ab8e..ed19280c4 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -1,24 +1,42 @@
+alias angular='frontend angular'
alias angularjs='frontend angularjs'
-alias aurajs='frontend aurajs'
alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
+alias bundlephobia='frontend bundlephobia'
alias caniuse='frontend caniuse'
alias codepen='frontend codepen'
alias compassdoc='frontend compassdoc'
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
+alias flowtype='frontend flowtype'
alias fontello='frontend fontello'
+alias github='frontend github'
alias html5please='frontend html5please'
+alias jestjs='frontend jestjs'
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
+alias nodejs='frontend nodejs'
alias npmjs='frontend npmjs'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
+alias typescript='frontend typescript'
alias unheap='frontend unheap'
+alias vuejs='frontend vuejs'
+
+function _frontend_fallback() {
+ local url
+ if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
+ url="https://duckduckgo.com/?sites=$1&q="
+ else
+ url="https://google.com/search?as_sitesearch=$1&as_q="
+ fi
+
+ echo "$url"
+}
function frontend() {
emulate -L zsh
@@ -26,27 +44,34 @@ function frontend() {
# define search context URLS
typeset -A urls
urls=(
- angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
- aurajs 'http://aurajs.com/api/#stq='
- bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
- bootsnipp 'http://bootsnipp.com/search?q='
- caniuse 'http://caniuse.com/#search='
- codepen 'http://codepen.io/search?q='
+ angular 'https://angular.io/?search='
+ angularjs $(_frontend_fallback 'angularjs.org')
+ bem $(_frontend_fallback 'bem.info')
+ bootsnipp 'https://bootsnipp.com/search?q='
+ bundlephobia 'https://bundlephobia.com/result?p='
+ caniuse 'https://caniuse.com/#search='
+ codepen 'https://codepen.io/search?q='
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 'http://emberjs.com/api/#stp=1&stq='
+ emberjs $(_frontend_fallback 'emberjs.com/')
+ flowtype $(_frontend_fallback 'flow.org/en/docs/')
fontello 'http://fontello.com/#search='
- html5please 'http://html5please.com/#'
+ github 'https://github.com/search?q='
+ html5please 'https://html5please.com/#'
+ jestjs $(_frontend_fallback 'jestjs.io')
jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q='
+ nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
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 'http://stackoverflow.com/search?q='
+ reactjs $(_frontend_fallback 'reactjs.org/')
+ smacss $(_frontend_fallback 'smacss.com')
+ stackoverflow 'https://stackoverflow.com/search?q='
+ typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s='
+ vuejs $(_frontend_fallback 'vuejs.org')
)
# show help for command list
@@ -57,9 +82,9 @@ function frontend() {
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 " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
- print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
- print -P " qunit, reactjs, smacss, stackoverflow, unheap"
+ 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 ""
@@ -73,17 +98,17 @@ function frontend() {
echo ""
echo "Valid contexts are:"
echo ""
- echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, "
- echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
- echo " qunit, reactjs, smacss, stackoverflow, unheap"
+ 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"
echo ""
return 1
fi
# build search url:
- # join arguments passed with '+', then append to search context URL
+ # join arguments passed with '%20', then append to search context URL
# TODO substitute for proper urlencode method
- url="${urls[$1]}${(j:+:)@[2,-1]}"
+ url="${urls[$1]}${(j:%20:)@[2,-1]}"
echo "Opening $url ..."