dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 678c92bb35bfff6ef6a0835b3d4469f6fac7e4d7
parent 1bf41622d35a75f8b52420bce3be391942973254
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Thu,  5 Aug 2021 11:24:43 +0200

w3m: move everything to surfraw, fix hit any key prompt

Add my searx to surfraw, now I just use the searx elvi if I want to
search searx specifically. Fixed the "hit any key" prompt by using
READ_SHELL in combination with fzf to prompt and read input (printf and
read doesn't show up on the screen).

Diffstat:
Asurfraw/elvi/searx | 21+++++++++++++++++++++
Dw3m/cgi-bin/get-query.cgi | 5-----
Dw3m/cgi-bin/searx-query.cgi | 5-----
Aw3m/cgi-bin/surfraw-searx.cgi | 4++++
Mw3m/cgi-bin/surfraw.cgi | 4+---
Mw3m/keymap | 8++------
6 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/surfraw/elvi/searx b/surfraw/elvi/searx @@ -0,0 +1,21 @@ +#!/bin/sh +# elvis: searx -- Search my Searx instance (search.alex.balgavy.eu) +. surfraw || exit 1 + +w3_usage_hook () { + cat <<EOF +Usage: $w3_argv0 [options] [search words]... +Description: + Search my Searx instance (search.alex.balgavy.eu) +EOF + w3_global_usage +} + +w3_config +w3_parse_args "$@" +if test -z "$w3_args"; then + w3_browse_url "https://search.alex.balgavy.eu" +else + escaped_args=`w3_url_of_arg $w3_args` + w3_browse_url "https://search.alex.balgavy.eu/searx/search?q=${escaped_args}" +fi diff --git a/w3m/cgi-bin/get-query.cgi b/w3m/cgi-bin/get-query.cgi @@ -1,5 +0,0 @@ -#!/bin/sh -# Ask for a string and save to /tmp/w3m_query -printf "Query: " -read -r query -printf "%s" "$query" > /tmp/w3m_query diff --git a/w3m/cgi-bin/searx-query.cgi b/w3m/cgi-bin/searx-query.cgi @@ -1,5 +0,0 @@ -#!/bin/sh -# Search contents of /tmp/w3m_query with searx -[ -f /tmp/w3m_query ] || exit -q="$(cat /tmp/w3m_query)" -printf "%s\r\nw3m-control: DELETE_PREVBUF\r\n" "w3m-control: GOTO https://search.alex.balgavy.eu/searx/search?q=$q" diff --git a/w3m/cgi-bin/surfraw-searx.cgi b/w3m/cgi-bin/surfraw-searx.cgi @@ -0,0 +1,4 @@ +#!/bin/sh +# Read query for Searx, save target URL to /tmp/w3m_target_url +query="$(fzf --print-query --prompt="Searx >> Search: " --info=hidden --layout=reverse </dev/null)" +surfraw -p searx "$query" > /tmp/w3m_target_url diff --git a/w3m/cgi-bin/surfraw.cgi b/w3m/cgi-bin/surfraw.cgi @@ -3,7 +3,5 @@ elvi="$(surfraw -elvi | sed '1,/LOCAL/d' | fzf | cut -f1)" [ -z "$elvi" ] && exit -clear -printf "%s >> Search: " "$elvi" -read -r query +query="$(fzf --print-query --prompt="$elvi >> Search: " --info=hidden --layout=reverse </dev/null)" surfraw -p "$elvi" "$query" > /tmp/w3m_target_url diff --git a/w3m/keymap b/w3m/keymap @@ -31,7 +31,7 @@ keymap ";" COMMAND keymap e EXTERN_LINK keymap ] EXTERN keymap M-e COMMAND 'SET_OPTION default_url=1 ; GOTO ; SET_OPTION default_url=0' -keymap M-f COMMAND 'SHELL ~/.config/w3m/cgi-bin/get-query.cgi ; GOTO /cgi-bin/searx-query.cgi' +keymap M-f COMMAND 'READ_SHELL ~/.config/w3m/cgi-bin/surfraw-searx.cgi ; GOTO /cgi-bin/goto-target-url.cgi' keymap M-k DEFINE_KEY keymap C-h HELP @@ -63,14 +63,10 @@ keymap M-r REINIT # Macros keymap SPCr PIPE_SHELL 'go-readability $W3M_URL | w3m -config ~/.config/w3m/config -T text/html -cols $(($(tput cols)*6/10))' -keymap SPCo SHELL 'open "$W3M_URL"' -keymap SPCt SHELL 'open "$W3M_CURRENT_LINK"' -keymap SPCy EXEC_SHELL 'printf "%s" $W3M_CURRENT_LINK | clc' -keymap SPCc EXEC_SHELL 'printf "%s" $W3M_URL | clc' keymap SPCs EXEC_SHELL 'pocket save $W3M_URL' keymap SPCl EXEC_SHELL 'pocket save $W3M_CURRENT_LINK' keymap SPCv EXEC_SHELL 'linkhandler "$W3M_CURRENT_LINK"' -keymap xs COMMAND 'EXEC_SHELL ~/.config/w3m/cgi-bin/surfraw.cgi ; GOTO /cgi-bin/goto-target-url.cgi' +keymap xs COMMAND 'READ_SHELL ~/.config/w3m/cgi-bin/surfraw.cgi ; GOTO /cgi-bin/goto-target-url.cgi' # ABORT Quit at once # ACCESSKEY Pop up accesskey menu