mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
Fix websearch plugin
Make yahoo search use the correct url. Quieten output from browser unless there is an error.
This commit is contained in:
parent
05b36f7d02
commit
ad72b56906
1 changed files with 13 additions and 4 deletions
|
|
@ -16,16 +16,19 @@ function web_search() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
local url="${WEB_SEARCH_PROTOCOL:-https}://www.$1.com"
|
||||
local url="${WEB_SEARCH_PROTOCOL:-https}://www.$1.${WEB_SEARCH_TLD:-com}"
|
||||
|
||||
# no keyword provided, simply open the search engine homepage
|
||||
if [[ $# -le 1 ]]; then
|
||||
$open_cmd "$url"
|
||||
return
|
||||
fi
|
||||
#
|
||||
# slightly different search syntax for duckduckgo and yahoo
|
||||
if [[ $1 == 'duckduckgo' ]]; then
|
||||
#slightly different search syntax for DDG
|
||||
url="${url}/?q="
|
||||
elif [[ $1 == 'yahoo' ]]; then
|
||||
url="${WEB_SEARCH_PROTOCOL:-https}://search.$1.com/search?p="
|
||||
else
|
||||
url="${url}/search?q="
|
||||
fi
|
||||
|
|
@ -37,8 +40,14 @@ function web_search() {
|
|||
done
|
||||
|
||||
url="${url%?}" # remove the last '+'
|
||||
nohup $open_cmd "$url"
|
||||
rm nohup.out
|
||||
local error_file="$(mktemp -t websearchXXXX)"
|
||||
$open_cmd "$url" 2> ${error_file}
|
||||
echo $url
|
||||
local exit_code=$?
|
||||
if [[ ${exit_code} != 0 ]]; then
|
||||
cat $error_file 2>&1
|
||||
fi
|
||||
return ${exit_code}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue