From ea053a6db1cb4bff8320067091d57d79ade4d6a3 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 19 Dec 2020 18:47:16 -0500 Subject: [PATCH] Attempt putting search parsing in a single function --- README.md | 2 ++ prompt | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cdaa340..1cee5d7 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,5 @@ Use it to automagically select and run terminal applications, send signals to da - command to clipboard - emoji select to clipboard - system of additional clipboards using /tmp files +- use attach-session -t . -c /dir for selecting multiplexer directory +- ddg fill options should be taken from bookmarks or history diff --git a/prompt b/prompt index f173c29..154f013 100755 --- a/prompt +++ b/prompt @@ -58,27 +58,53 @@ file both" | dmenu -i -p "Screenshot") - if test $method = "file"; then + if [ $method = "file" ]; then scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\ -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png fi -} - if test $method = "clipboard"; then + + if [ $method = "clipboard" ]; then scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\ -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\ -e "xclip $f; rm $f" fi - if test $method = "both"; then + if [ $method = "both" ]; then scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\ -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\ -e "xclip $f;" fi +} + +ddg() { + search_string="$(printf "" | dmenu -p 'ddg')" + rawurlencode "$search_string" +} + +rawurlencode() { + string_length=$(expr length $1) + char=''; new_string=''; + + i=1 + while [ $i -le $string_length ] + do + 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) + done + printf "$newstring\n" + + case "$1" in + [-_.~a-zA-Z0-9] ) result=$1; printf $result;; + * ) result=$(printf '%%%02x' "'$1"); printf %$result;; + esac +} case $1 in launch) launch;; action) action;; cmd) action;; - ddg) action;; + ddg) ddg;; *) printf "Invalid argument";; esac