tianyun 1 year ago
parent
commit
af84b9507d
1 changed files with 10 additions and 4 deletions
  1. 10 4
      sh_config.sh

+ 10 - 4
sh_config.sh

@@ -233,14 +233,20 @@ concat_params() {
     echo "没有传入参数"
   fi
 }
-
+function url_encode() {
+    echo "$1" | sed 's/ /%20/g'
+}
 function bing() {
-  # 获取拼接后的搜索参数
-  search_query=$(concat_params "$@")
   ## 如果是windows系统,则使用start,否则使用open,后面的参数可以有多个空格
   if [[ "$OSTYPE" == "msys"* ]]; then
+    search_query=$(concat_params "$@")
     start "https://www.bing.com/search?q=$search_query"
   else
-    open "https://www.bing.com/search?q=$search_query"
+      search_query=""
+      for query in "$@"; do
+          search_query+=" $query"
+      done
+      search_query=$(url_encode "$search_query")
+    open "https://www.bing.com/search?q=${search_query}"
   fi
 }