mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 13:50:09 +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!
|
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
|
## Author
|
||||||
|
|
||||||
**Wilson Mendes (willmendesneto)**
|
**Wilson Mendes (willmendesneto)**
|
||||||
|
|
|
@ -27,6 +27,17 @@ alias typescript='frontend typescript'
|
||||||
alias unheap='frontend unheap'
|
alias unheap='frontend unheap'
|
||||||
alias vuejs='frontend vuejs'
|
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() {
|
function frontend() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
|
@ -34,8 +45,8 @@ function frontend() {
|
||||||
typeset -A urls
|
typeset -A urls
|
||||||
urls=(
|
urls=(
|
||||||
angular 'https://angular.io/?search='
|
angular 'https://angular.io/?search='
|
||||||
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
|
angularjs $(_frontend_fallback 'angularjs.org')
|
||||||
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
|
bem $(_frontend_fallback 'bem.info')
|
||||||
bootsnipp 'https://bootsnipp.com/search?q='
|
bootsnipp 'https://bootsnipp.com/search?q='
|
||||||
bundlephobia 'https://bundlephobia.com/result?p='
|
bundlephobia 'https://bundlephobia.com/result?p='
|
||||||
caniuse 'https://caniuse.com/#search='
|
caniuse 'https://caniuse.com/#search='
|
||||||
|
@ -43,24 +54,24 @@ function frontend() {
|
||||||
compassdoc 'http://compass-style.org/search?q='
|
compassdoc 'http://compass-style.org/search?q='
|
||||||
cssflow 'http://www.cssflow.com/search?q='
|
cssflow 'http://www.cssflow.com/search?q='
|
||||||
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
||||||
emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q='
|
emberjs $(_frontend_fallback 'emberjs.com/')
|
||||||
flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q='
|
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
||||||
fontello 'http://fontello.com/#search='
|
fontello 'http://fontello.com/#search='
|
||||||
github 'https://github.com/search?q='
|
github 'https://github.com/search?q='
|
||||||
html5please 'https://html5please.com/#'
|
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='
|
jquery 'https://api.jquery.com/?s='
|
||||||
lodash 'https://devdocs.io/lodash/index#'
|
lodash 'https://devdocs.io/lodash/index#'
|
||||||
mdn 'https://developer.mozilla.org/search?q='
|
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='
|
npmjs 'https://www.npmjs.com/search?q='
|
||||||
qunit 'https://api.qunitjs.com/?s='
|
qunit 'https://api.qunitjs.com/?s='
|
||||||
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
|
reactjs $(_frontend_fallback 'reactjs.org/')
|
||||||
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
|
smacss $(_frontend_fallback 'smacss.com')
|
||||||
stackoverflow 'https://stackoverflow.com/search?q='
|
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='
|
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
|
# show help for command list
|
||||||
|
|
Loading…
Reference in a new issue