commit 75e1037038670f6723a2d237c432afaa8e8adb5e
parent 4114e724afd0c20e747ba8c88d5679057d7599eb
Author: Alex Balgavy <alex@balgavy.eu>
Date: Sun, 28 Nov 2021 12:35:27 +0100
w3m: split out fzf surfraw into a separate script
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/scripts/fzf-surfraw b/scripts/fzf-surfraw
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Fzf search engine, print search URL
+elvi="$(surfraw -elvi | sed '1,/LOCAL/d' | fzf | cut -f1)"
+[ -z "$elvi" ] && exit
+query="$(fzf --print-query --prompt="$elvi >> Search: " --info=hidden --layout=reverse </dev/null)"
+surfraw -p "$elvi" "$query"
diff --git a/w3m/cgi-bin/surfraw.cgi b/w3m/cgi-bin/surfraw.cgi
@@ -1,7 +1,5 @@
#!/bin/sh
# Ask for search engine & query, save target URL to /tmp/w3m_target_url
-elvi="$(surfraw -elvi | sed '1,/LOCAL/d' | fzf | cut -f1)"
-[ -z "$elvi" ] && exit
-
-query="$(fzf --print-query --prompt="$elvi >> Search: " --info=hidden --layout=reverse </dev/null)"
-surfraw -p "$elvi" "$query" > /tmp/w3m_target_url
+query_url="$(fzf-surfraw)"
+[ -n "$query_url" ] || exit
+printf '%s' "$query_url" > /tmp/w3m_target_url