Browse Source

Use seperate search and encode functions instead

master
= 3 years ago
parent
commit
d0f61568eb
1 changed files with 8 additions and 9 deletions
  1. +8
    -9
      prompt

+ 8
- 9
prompt View File

@@ -78,23 +78,22 @@ both" |


ddg() { ddg() {
search_string="$(printf "" | dmenu -p 'ddg')" search_string="$(printf "" | dmenu -p 'ddg')"
rawurlencode "$search_string"
}

rawurlencode() {
string_length=$(expr length $1)
string_length=$(expr length "$search_string")
char=''; new_string=''; char=''; new_string='';


i=1 i=1
while [ $i -le $string_length ] while [ $i -le $string_length ]
do do
char=$(expr substr $search_string $i 1)
new_string=$new_string$(rawurlencode $char)
printf "this is newstring %s\n" $new_string
char=$(expr substr "$search_string" $i 1)
new_string="$new_string$(rawurlencode "$char")"
# printf "this is newstring %s\n" "$new_string"
i=$(expr $i + 1) i=$(expr $i + 1)
done done
printf "$newstring\n"
search="https://duckduckgo.com/?q=$new_string"
brave-browser "$search"
}


rawurlencode() {
case "$1" in case "$1" in
[-_.~a-zA-Z0-9] ) result=$1; printf $result;; [-_.~a-zA-Z0-9] ) result=$1; printf $result;;
* ) result=$(printf '%%%02x' "'$1"); printf %$result;; * ) result=$(printf '%%%02x' "'$1"); printf %$result;;


Loading…
Cancel
Save