w3m plugins

pull/41/head
gotbletu 4 years ago
parent 2920edc90a
commit b12a7f0b8b

@ -0,0 +1,42 @@
#!/usr/bin/env bash
### _ _ _ _
### __ _ ___ | |_| |__ | | ___| |_ _ _
### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
###| (_| | (_) | |_| |_) | | __/ |_| |_| |
### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
### |___/
### https://www.youtube.com/user/gotbletu
### https://twitter.com/gotbletu
### https://github.com/gotbletu
### gotbletu@gmail.com
###
### Author : gotbletu
### Name : fzf_surfraw.cgi
### Version : 0.2
### Date : 2020-04-27
### Description : interactive surfraw smart prefix search engine (mainly use within w3m web browser)
### Depends On : surfraw fzf xsel gawk coreutils grep procps-ng
### Video Demo : https://youtu.be/p5NZb8f8AHA
### References : https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
### Setup
# vim ~/.w3m/keymap
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi"
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi"
clear
# select your elvi
PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e | awk '{print $1}')
# exit script if no elvi is selected (e.g hit ESC)
if [ "$PREFIX" = "" ]; then exit; fi
# get user input
read -r -e -p " $PREFIX >> Enter Your Search Keyword: " INPUT
# print proper url and copy to primary clipboard (aka highlighted clipboard) and tmux clipboard
surfraw -browser=echo "$PREFIX" "$INPUT" | xsel -p
# pidof tmux >/dev/null && tmux set-buffer "$(surfraw -browser=echo "$PREFIX" "$INPUT")"

@ -0,0 +1,40 @@
#!/usr/bin/env bash
### _ _ _ _
### __ _ ___ | |_| |__ | | ___| |_ _ _
### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
###| (_| | (_) | |_| |_) | | __/ |_| |_| |
### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
### |___/
### https://www.youtube.com/user/gotbletu
### https://twitter.com/gotbletu
### https://github.com/gotbletu
### gotbletu@gmail.com
###
### Author : gotbletu
### Name : fzf_surfraw_tmux.cgi
### Version : 0.2
### Date : 2020-04-27
### Description : interactive surfraw smart prefix search engine (mainly use within w3m web browser)
### Depends On : surfraw fzf tmux gawk coreutils grep procps-ng
### Video Demo : https://youtu.be/p5NZb8f8AHA
### References : https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
### Setup
# vim ~/.w3m/keymap
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi"
clear
# select your elvi
PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e | awk '{print $1}')
# exit script if no elvi is selected (e.g hit ESC)
if [ "$PREFIX" = "" ]; then exit; fi
# get user input
read -r -e -p " $PREFIX >> Enter Your Search Keyword: " INPUT
# print proper url and copy to primary clipboard (aka highlighted clipboard) and tmux clipboard
# surfraw -browser=echo "$PREFIX" "$INPUT" | xsel -p
pidof tmux >/dev/null && tmux set-buffer "$(surfraw -browser=echo "$PREFIX" "$INPUT")"

@ -0,0 +1,34 @@
#!/usr/bin/env python2
# Author: Alexandre Boeglin
# Info: send magnet links to your torrent client
# Source: http://boeglin.org/blog/index.php?entry=Handling-magnet-URIs-with-w3m
########## SETUP ##########################
# 1. vim ~/.w3m/urimethodmap
# magnet: file:/cgi-bin/magnet.py?%s
# 2. mv magnet.py ~/.w3m/cgi-bin/magnet.py
# 3. edit ==> cmd_list = ("transmission-remote", "-a", uri)
# 4. chmod +x ~/.w3m/cgi-bin/magnet.py
###########################################
# coding=utf-8
import sys
import os
import subprocess
uri = os.environ.get('QUERY_STRING')
referer = os.environ.get('HTTP_REFERER')
if not uri:
print
print "Error: No URI"
sys.exit()
cmd_list = ("transmission-remote", "-a", uri)
subprocess.call(cmd_list)
if referer:
print "HTTP/1.1 303 See Other"
print "Location: %s" % referer

@ -0,0 +1,25 @@
#!/usr/bin/env sh
### __ _ _
### / _| ___| (_)_ __ ___ ___ __ _ __ _
###| |_ / _ \ | | '_ \ / _ \/ __|/ _` |/ _` |
###| _| __/ | | |_) | __/\__ \ (_| | (_| |
###|_| \___|_|_| .__/ \___||___/\__,_|\__,_|
### |_|
### https://github.com/felipesaa
###
### Author : felipesaa
### Name : goto_clipboard.cgi
### Version : 0.1
### Date : 2018-09-30
### Description : paste and go feature for w3m web browser using system clipboard (aka ctrl+v)
### Depends On : w3m xsel
### Video Demo : https://youtu.be/p5NZb8f8AHA
### Source : https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
### Install : put this script in /usr/lib/w3m/cgi-bin/
#GOTO url in clipboard in current page. If the clipboard has a
#"non url string/nothing" an blank page is shown.
printf "%s\r\n" "W3m-control: GOTO $(xsel -ob)";
#delete the buffer (element in history) created between the current page and
#the searched page by calling this script.
printf "W3m-control: DELETE_PREVBUF\r\n"

@ -0,0 +1,28 @@
#!/usr/bin/env sh
### _ _ _ _
### __ _ ___ | |_| |__ | | ___| |_ _ _
### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
###| (_| | (_) | |_| |_) | | __/ |_| |_| |
### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
### |___/
### https://www.youtube.com/user/gotbletu
### https://twitter.com/gotbletu
### https://github.com/gotbletu
### gotbletu@gmail.com
###
### Author : gotbletu
### Name : goto_clipboard_primary.cgi
### Version : 0.1
### Date : 2020-04-26
### Description : paste and go feature for w3m web browser using system clipboard (primary aka shift+insert)
### Depends On : w3m xsel
### Video Demo : https://youtu.be/p5NZb8f8AHA
### References : https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
### Install : put this script in /usr/lib/w3m/cgi-bin/
#GOTO url in clipboard in current page. If the clipboard has a
#"non url string/nothing" an blank page is shown.
printf "%s\r\n" "W3m-control: GOTO $(xsel -op)";
#delete the buffer (element in history) created between the current page and
#the searched page by calling this script.
printf "W3m-control: DELETE_PREVBUF\r\n"

@ -0,0 +1,28 @@
#!/usr/bin/env sh
### _ _ _ _
### __ _ ___ | |_| |__ | | ___| |_ _ _
### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
###| (_| | (_) | |_| |_) | | __/ |_| |_| |
### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
### |___/
### https://www.youtube.com/user/gotbletu
### https://twitter.com/gotbletu
### https://github.com/gotbletu
### gotbletu@gmail.com
###
### Author : gotbletu
### Name : goto_tmux_clipboard.cgi
### Version : 0.1
### Date : 2020-04-26
### Description : paste and go feature for w3m web browser using tmux clipboard
### Depends On : w3m tmux
### Video Demo : https://youtu.be/p5NZb8f8AHA
### References : https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
### Install : put this script in /usr/lib/w3m/cgi-bin/
#GOTO url in clipboard in current page. If the clipboard has a
#"non url string/nothing" an blank page is shown.
printf "%s\r\n" "W3m-control: GOTO $(tmux paste-buffer)";
#delete the buffer (element in history) created between the current page and
#the searched page by calling this script.
printf "W3m-control: DELETE_PREVBUF\r\n"

@ -0,0 +1,66 @@
# W3M Prefix Search Engines 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
* tutorial video: [Link](https://youtu.be/p5NZb8f8AHA)
* offical website: [Link](https://www.youtube.com/user/gotbletu)
### install requirements
w3m fzf surfraw
### install scripts to root directory
Download at [root-cgi-bin](w3m_plugins/root-cgi-bin)
----
# save it to
/usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi
/usr/lib/w3m/cgi-bin/goto_clipboard.cgi
/usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi
----
### install scripts to local directory
Download at [cgi-bin](w3m_plugins/cgi-bin)
----
# save it to
~/.w3m/cgi-bin/fzf_surfraw.cgi
~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi
----
### configuration
vim ~/.w3m/keymap
# for x sessions
keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi"
keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi"
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi"
# for tmux users or headless server
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi"
### references
- https://youtu.be/p5NZb8f8AHA
- https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m
- [W3M Playlist](https://www.youtube.com/playlist?list=PLqv94xWU9zZ35Yv0s6zMID5JoS8qu19Kh)
- [Surfraw Playlist](https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz)
- [FZF Playlist](https://www.youtube.com/playlist?list=PLqv94xWU9zZ2fMsMMDF4PjtNHCeBFbggD)
### contact
_ _ _ _
__ _ ___ | |_| |__ | | ___| |_ _ _
/ _` |/ _ \| __| '_ \| |/ _ \ __| | | |
| (_| | (_) | |_| |_) | | __/ |_| |_| |
\__, |\___/ \__|_.__/|_|\___|\__|\__,_|
|___/
- http://www.youtube.com/user/gotbletu
- https://twitter.com/gotbletu
- https://github.com/gotbletu
- gotbletu@gmail.com
Loading…
Cancel
Save