mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 00:40:07 +00:00
frontend-search: add duckduckgo as an option for fallback search (#7973)
This commit is contained in:
parent
59c1ec80aa
commit
6d2221e697
2 changed files with 25 additions and 10 deletions
|
@ -62,6 +62,10 @@ Available search contexts are:
|
|||
|
||||
If you want to have another context, open an Issue and tell us!
|
||||
|
||||
## Fallback search behaviour
|
||||
|
||||
The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
|
||||
|
||||
## Author
|
||||
|
||||
**Wilson Mendes (willmendesneto)**
|
||||
|
|
|
@ -27,6 +27,17 @@ 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
|
||||
|
||||
|
@ -34,8 +45,8 @@ function frontend() {
|
|||
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='
|
||||
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='
|
||||
|
@ -43,24 +54,24 @@ function frontend() {
|
|||
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='
|
||||
emberjs $(_frontend_fallback 'emberjs.com/')
|
||||
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
||||
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='
|
||||
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 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_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='
|
||||
reactjs $(_frontend_fallback 'reactjs.org/')
|
||||
smacss $(_frontend_fallback 'smacss.com')
|
||||
stackoverflow 'https://stackoverflow.com/search?q='
|
||||
typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q='
|
||||
typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
|
||||
unheap 'http://www.unheap.com/?s='
|
||||
vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q='
|
||||
vuejs $(_frontend_fallback 'vuejs.org')
|
||||
)
|
||||
|
||||
# show help for command list
|
||||
|
|
Loading…
Reference in a new issue