1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 08:20:09 +00:00
ohmyzsh/plugins/frontend-search/frontend-search.plugin.zsh

92 lines
3.4 KiB
Bash
Raw Normal View History

2015-08-31 17:12:05 +00:00
alias angularjs='frontend angularjs'
alias aurajs='frontend aurajs'
alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
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 fontello='frontend fontello'
alias html5please='frontend html5please'
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
alias npmjs='frontend npmjs'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
alias unheap='frontend unheap'
2014-06-20 02:27:40 +00:00
function frontend() {
emulate -L zsh
# define search context URLS
typeset -A urls
urls=(
2019-05-04 20:17:28 +00:00
angularjs 'https://angular.io/?search='
aurajs 'http://aurajs.com/api/#stq='
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
bootsnipp 'https://bootsnipp.com/search?q='
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://emberjs.com/api/#stp=1&stq='
fontello 'http://fontello.com/#search='
html5please 'http://html5please.com/#'
jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?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='
unheap 'http://www.unheap.com/?s='
)
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:17:28 +00:00
print -P "sample"
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 ""
2016-02-21 13:09:27 +00:00
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 ""
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 ""
2016-02-21 13:09:27 +00:00
echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, "
echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
echo " qunit, reactjs, smacss, stackoverflow, unheap"
2014-06-20 02:27:40 +00:00
echo ""
return 1
fi
# build search url:
# join arguments passed with '+', then append to search context URL
# TODO substitute for proper urlencode method
url="${urls[$1]}${(j:+:)@[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
}