Back to Ohmyzsh

web-search plugin

plugins/web-search/README.md

latest3.9 KB
Original Source

web-search plugin

This plugin adds aliases for searching with Google, Wiki, Bing, YouTube and other popular services.

Open your ~/.zshrc file and enable the web-search plugin:

zsh
plugins=( ... web-search)

Usage

You can use the web-search plugin in these two forms:

  • web_search <context> <term> [more terms if you want]
  • <context> <term> [more terms if you want]

For example, these two are equivalent:

zsh
$ web_search google oh-my-zsh
$ google oh-my-zsh

Available search contexts are:

ContextURL
binghttps://www.bing.com/search?q=
googlehttps://www.google.com/search?q=
brs or bravehttps://search.brave.com/search?q=
yahoohttps://search.yahoo.com/search?p=
ddg or duckduckgohttps://www.duckduckgo.com/?q=
sp or startpagehttps://www.startpage.com/do/search?q=
yandexhttps://yandex.ru/yandsearch?text=
githubhttps://github.com/search?q=
baiduhttps://www.baidu.com/s?wd=
ecosiahttps://www.ecosia.org/search?q=
goodreadshttps://www.goodreads.com/search?q=
qwanthttps://www.qwant.com/?q=
giverohttps://www.givero.com/search?q=
stackoverflowhttps://stackoverflow.com/search?q=
wolframalphahttps://wolframalpha.com/input?i=
archivehttps://web.archive.org/web/*/
scholarhttps://scholar.google.com/scholar?q=
askhttps://www.ask.com/web?q=
youtubehttps://www.youtube.com/results?search_query=
deeplhttps://www.deepl.com/translator#auto/auto/
dockerhubhttps://hub.docker.com/search?q=
gemshttps://rubygems.org/search?query=
npmpkghttps://www.npmjs.com/search?q=
packagisthttps://packagist.org/?query=
gopkghttps://pkg.go.dev/search?m=package&q=
chatgpthttps://chatgpt.com/?q=
claudeaihttps://claude.ai/new?q=
grokhttps://grok.com/?q=
reddithttps://www.reddit.com/search/?q=
ppaihttps://www.perplexity.ai/search/new?q=
rscratehttps://crates.io/search?q=
rsdochttps://docs.rs/releases/search?query=

Also there are aliases for bang-searching DuckDuckGo:

ContextBang
wiki!w
news!n
map!m
image!i
ducky!

Custom search engines

If you want to add other search contexts to the plugin, you can use the $ZSH_WEB_SEARCH_ENGINES variable. Set it before Oh My Zsh is sourced, with the following format:

zsh
ZSH_WEB_SEARCH_ENGINES=(
    <context> <URL>
    <context> <URL>
)

where <context> is the name of the search context, and <URL> a URL of the same type as the search contexts above. For example, to add reddit, you'd do:

zsh
ZSH_WEB_SEARCH_ENGINES=(reddit "https://www.reddit.com/search/?q=")

These custom search engines will also be turned to aliases, so you can both do web_search reddit <query> or reddit <query>.