From 0fd11130a3541e33aded41ff64bec47c6ceefa39 Mon Sep 17 00:00:00 2001 From: Pierre Gimalac Date: Wed, 3 Jun 2020 18:28:47 +0200 Subject: web-search: add Wayback Archive (#8784) --- plugins/web-search/README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/web-search/README.md') diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index 9c01f0724..81908fb94 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -40,6 +40,7 @@ Available search contexts are: | `givero` | `https://www.givero.com/search?q=` | | `stackoverflow` | `https://stackoverflow.com/search?q=` | | `wolframalpha` | `https://wolframalpha.com/input?i=` | +| `archive` | `https://web.archive.org/web/*/` | Also there are aliases for bang-searching DuckDuckGo: -- cgit v1.2.3-70-g09d2 From 60442dc47b9092375bb41a1f803b25389c834427 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 10 Jun 2020 12:04:14 +0200 Subject: web-search: allow custom search engines --- plugins/web-search/README.md | 24 ++++++++++++++++++++++++ plugins/web-search/web-search.plugin.zsh | 13 ++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'plugins/web-search/README.md') diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index 81908fb94..ad5080a44 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -52,3 +52,27 @@ Also there are aliases for bang-searching DuckDuckGo: | `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=( + + +) +``` + +where `` is the name of the search context, and `` 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 ` or `reddit `. diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 326a30745..e8842d906 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -6,6 +6,7 @@ function web_search() { # define search engine URLS typeset -A urls urls=( + $ZSH_WEB_SEARCH_ENGINES google "https://www.google.com/search?q=" bing "https://www.bing.com/search?q=" yahoo "https://search.yahoo.com/search?p=" @@ -25,7 +26,7 @@ function web_search() { # check whether the search engine is supported if [[ -z "$urls[$1]" ]]; then - echo "Search engine $1 not supported." + echo "Search engine '$1' not supported." return 1 fi @@ -67,3 +68,13 @@ alias youtube='web_search duckduckgo \!yt' alias map='web_search duckduckgo \!m' alias image='web_search duckduckgo \!i' alias ducky='web_search duckduckgo \!' + +# other search engine aliases +if [[ ${#ZSH_WEB_SEARCH_ENGINES} -gt 0 ]]; then + typeset -A engines + engines=($ZSH_WEB_SEARCH_ENGINES) + for key in ${(k)engines}; do + alias "$key"="web_search $key" + done + unset engines key +fi -- cgit v1.2.3-70-g09d2 From da01dc91bfe6a5f176ad94d183b0bd05c91993c5 Mon Sep 17 00:00:00 2001 From: Małgorzata Basińska Date: Wed, 10 Jun 2020 12:05:12 +0200 Subject: web-search: add Google Scholar (#9014) --- plugins/web-search/README.md | 1 + plugins/web-search/web-search.plugin.zsh | 2 ++ 2 files changed, 3 insertions(+) (limited to 'plugins/web-search/README.md') diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index ad5080a44..da90f90a0 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -41,6 +41,7 @@ Available search contexts are: | `stackoverflow` | `https://stackoverflow.com/search?q=` | | `wolframalpha` | `https://wolframalpha.com/input?i=` | | `archive` | `https://web.archive.org/web/*/` | +| `scholar` | `https://scholar.google.com/scholar?q=` | Also there are aliases for bang-searching DuckDuckGo: diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index e8842d906..0a2b8809e 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -22,6 +22,7 @@ function web_search() { stackoverflow "https://stackoverflow.com/search?q=" wolframalpha "https://www.wolframalpha.com/input/?i=" archive "https://web.archive.org/web/*/" + scholar "https://scholar.google.com/scholar?q=" ) # check whether the search engine is supported @@ -60,6 +61,7 @@ alias givero='web_search givero' alias stackoverflow='web_search stackoverflow' alias wolframalpha='web_search wolframalpha' alias archive='web_search archive' +alias scholar='web_search scholar' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' -- cgit v1.2.3-70-g09d2