diff --git a/README.md b/README.md index 77d59bc..935ff3c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ web-search plugin ----------------- -This plugin allow aliases for searching from terminal with some popular web search engines. +This plugin allows aliases for searching from terminal with some popular web search engines. -## Installation +## Installation ```sh git clone https://github.com/sinetoami/web-search.git "$ZSH_CUSTOM/plugins/web-search" @@ -28,6 +28,7 @@ The results are the same for both ways. | alias | engine | | --- | --- | | `ddg` | `https://www.duckduckgo.com/?q=` | +| `brave` | `https://www.search.brave.com/?q=` | | `google` | `https://www.google.com/search?q=` | | `yahoo` | `https://search.yahoo.com/search?p=` | | `github` | `https://github.com/search?q=` | diff --git a/web_search.plugin.zsh b/web_search.plugin.zsh index a104430..1ecc8ab 100644 --- a/web_search.plugin.zsh +++ b/web_search.plugin.zsh @@ -7,7 +7,7 @@ function web_search() { [[ "$OSTYPE" = linux* ]] && open_cmd='xdg-open' [[ "$OSTYPE" = darwin* ]] && open_cmd='open' - pattern='(google|duckduckgo|bing|yahoo|github|youtube)' + pattern='(google|duckduckgo|bing|yahoo|github|youtube|brave)' # check whether the search engine is supported if [[ $1 =~ pattern ]]; @@ -17,7 +17,7 @@ function web_search() { fi local url - [[ "$1" == 'yahoo' ]] && url="https://search.yahoo.com" || url="https://www.$1.com" + [[ "$1" == 'yahoo' || "$1" == 'brave' ]] && url="https://search.$1.com" || url="https://www.$1.com" # no keyword provided, simply open the search engine homepage if [[ $# -le 1 ]]; then @@ -26,6 +26,7 @@ function web_search() { fi typeset -A search_syntax=( + brave "/search?q=" google "/search?q=" bing "/search?q=" github "/search?q=" @@ -46,6 +47,7 @@ function web_search() { nohup $open_cmd "$url" &> /dev/null } +alias brave='web_search brave' alias bing='web_search bing' alias google='web_search google' alias yahoo='web_search yahoo'