From 544fa29cca16d3bc84d2f38af91faaa8ecbac859 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Mon, 30 Aug 2021 16:29:35 +0200 Subject: [PATCH] dmsearch: provide urlencode in script --- misc/dmsearch | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/misc/dmsearch b/misc/dmsearch index 1436845..01155a4 100755 --- a/misc/dmsearch +++ b/misc/dmsearch @@ -73,6 +73,20 @@ dmdefault() { fi } +# adapted from https://gist.github.com/lucasad/6474224 +# urlencodes the string given as argument, or, if no string is given, its input +# on stdin +urlencode() { + setopt localoptions extendedglob + local input + if [[ -n $1 ]]; then + input=( ${(s::)1} ) + else + input=( ${(s::)$(/dev/null; then + echo >&2 "Module s_${search} starting" qs=$(s_${search}) else + echo >&2 "No module for ${search}, using generic" qs="${SERCHILO}${search}" result=$(dmhist "$search" | dmenu -i -l 20 -p "params to $search") dmhistadd "$search" "$result"