shownotes-w3m-rice/w3m_prefix_search.md
2021-07-03 16:23:15 -07:00

3.0 KiB

W3M Prefix Search Engines Searches Using FZF and Surfraw

improving w3m by having a quick way to search multiple search engines or even custom search engines via the power of surfraw elvi

tags: linux w3m omnibar address bar quick w3m smart search fzf fuzzy finder surfraw tmux workaround current url

install requirements

w3m surfraw fzf gawk coreutils grep

install script to local directory

Download at cgi-bin


~/.w3m/cgi-bin/fzf_surfraw.cgi
~/.w3m/cgi-bin/goto_clipboard.cgi
~/.w3m/cgi-bin/goto_clipboard_primary.cgi
~/.w3m/cgi-bin/goto_tmux_clipboard.cgi
~/.w3m/cgi-bin/goto_w3m_clipboard.cgi

chmod +x ~/.w3m/cgi-bin/*.cgi

configuration

vim ~/.w3m/keymap

# search with surfraw (no clipboard required)
keymap  xs      COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; BACK ; GOTO file:/cgi-bin/goto_w3m_clipboard.cgi"
keymap  XS      COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; BACK ; TAB_GOTO file:/cgi-bin/goto_w3m_clipboard.cgi"

# yank url to multiple clipboard
keymap  yy      EXTERN_LINK "url=%s ; printf "%b" "$url" > /tmp/clipbrd.txt ; printf "%b" "$url" | xsel -b ; printf "%b" "$url" | tmux load-buffer -"
keymap  YY      EXTERN      "url=%s ; printf "%b" "$url" > /tmp/clipbrd.txt ; printf "%b" "$url" | xsel -b ; printf "%b" "$url" | tmux load-buffer -"

# paste url and go
keymap  pp      GOTO        file:/cgi-bin/goto_clipboard.cgi
keymap  PP      TAB_GOTO    file:/cgi-bin/goto_clipboard.cgi
keymap  pt      GOTO        file:/cgi-bin/goto_tmux_clipboard.cgi
keymap  PT      TAB_GOTO    file:/cgi-bin/goto_tmux_clipboard.cgi
keymap  pw      GOTO        file:/cgi-bin/goto_w3m_clipboard.cgi
keymap  PW      TAB_GOTO    file:/cgi-bin/goto_w3m_clipboard.cgi

change config settings

sed -i 's@cgi_bin.*@cgi_bin ~/.w3m/cgi-bin:/usr/lib/w3m/cgi-bin:/usr/local/libexec/w3m/cgi-bin@g' ~/.w3m/config
sed -i 's:default_url.*:default_url 1:g' ~/.w3m/config

usage example

$ w3m google.com
then press xs or XS to use surfraw for smart search

references

contact

             _   _     _      _
  __ _  ___ | |_| |__ | | ___| |_ _   _
 / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
| (_| | (_) | |_| |_) | |  __/ |_| |_| |
 \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
 |___/