diff options
Diffstat (limited to 'plugins/web-search')
| -rw-r--r-- | plugins/web-search/README.md | 27 | ||||
| -rw-r--r-- | plugins/web-search/web-search.plugin.zsh | 34 |
2 files changed, 53 insertions, 8 deletions
diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index 6e4b4d7b8..8d74a08c0 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -45,16 +45,29 @@ Available search contexts are: | `scholar` | `https://scholar.google.com/scholar?q=` | | `ask` | `https://www.ask.com/web?q=` | | `youtube` | `https://www.youtube.com/results?search_query=` | +| `deepl` | `https://www.deepl.com/translator#auto/auto/` | +| `dockerhub` | `https://hub.docker.com/search?q=` | +| `gems` | `https://rubygems.org/search?query=` | +| `npmpkg` | `https://www.npmjs.com/search?q=` | +| `packagist` | `https://packagist.org/?query=` | +| `gopkg` | `https://pkg.go.dev/search?m=package&q=` | +| `chatgpt` | `https://chatgpt.com/?q=` | +| `claudeai` | `https://claude.ai/new?q=` | +| `grok` | `https://grok.com/?q=` | +| `reddit` | `https://www.reddit.com/search/?q=` | +| `ppai` | `https://www.perplexity.ai/search/new?q=` | +| `rscrate` | `https://crates.io/search?q=` | +| `rsdoc` | `https://docs.rs/releases/search?query=` | Also there are aliases for bang-searching DuckDuckGo: -| Context | Bang | -| --------- | ----- | -| `wiki` | `!w` | -| `news` | `!n` | -| `map` | `!m` | -| `image` | `!i` | -| `ducky` | `!` | +| Context | Bang | +| ------- | ---- | +| `wiki` | `!w` | +| `news` | `!n` | +| `map` | `!m` | +| `image` | `!i` | +| `ducky` | `!` | ### Custom search engines diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index a8848fd95..93237f4e2 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -26,6 +26,19 @@ function web_search() { scholar "https://scholar.google.com/scholar?q=" ask "https://www.ask.com/web?q=" youtube "https://www.youtube.com/results?search_query=" + deepl "https://www.deepl.com/translator#auto/auto/" + dockerhub "https://hub.docker.com/search?q=" + gems "https://rubygems.org/search?query=" + npmpkg "https://www.npmjs.com/search?q=" + packagist "https://packagist.org/?query=" + gopkg "https://pkg.go.dev/search?m=package&q=" + chatgpt "https://chatgpt.com/?q=" + grok "https://grok.com/?q=" + claudeai "https://claude.ai/new?q=" + reddit "https://www.reddit.com/search/?q=" + ppai "https://www.perplexity.ai/search/new?q=" + rscrate "https://crates.io/search?q=" + rsdoc "https://docs.rs/releases/search?query=" ) # check whether the search engine is supported @@ -36,9 +49,14 @@ function web_search() { # search or go to main page depending on number of arguments passed if [[ $# -gt 1 ]]; then + # if search goes in the query string ==> space as +, otherwise %20 + # see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20 + local param="-P" + [[ "$urls[$1]" == *\?*= ]] && param="" + # build search url: # join arguments passed with '+', then append to search engine URL - url="${urls[$1]}$(omz_urlencode ${@[2,-1]})" + url="${urls[$1]}$(omz_urlencode $param ${(s: :)@[2,-1]})" else # build main page url: # split by '/', then rejoin protocol (1) and domain (2) parts with '//' @@ -68,6 +86,19 @@ alias archive='web_search archive' alias scholar='web_search scholar' alias ask='web_search ask' alias youtube='web_search youtube' +alias deepl='web_search deepl' +alias dockerhub='web_search dockerhub' +alias gems='web_search gems' +alias npmpkg='web_search npmpkg' +alias packagist='web_search packagist' +alias gopkg='web_search gopkg' +alias chatgpt='web_search chatgpt' +alias grok='web_search grok' +alias claudeai='web_search claudeai' +alias reddit='web_search reddit' +alias ppai='web_search ppai' +alias rscrate='web_search rscrate' +alias rsdoc='web_search rsdoc' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' @@ -85,3 +116,4 @@ if [[ ${#ZSH_WEB_SEARCH_ENGINES} -gt 0 ]]; then done unset engines key fi + |
