aboutsummaryrefslogtreecommitdiffstats
path: root/.w3m/cgi-bin
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
committerterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
commit6e528248414e330c9e25e81596ab47b8b8a5b701 (patch)
treee1aa41a7f3198eeac187e6177ec7d4a33db229d3 /.w3m/cgi-bin
downloadscripts-6e528248414e330c9e25e81596ab47b8b8a5b701.tar.gz
scripts-6e528248414e330c9e25e81596ab47b8b8a5b701.zip
first commitmaster
Diffstat (limited to '')
-rwxr-xr-x.w3m/cgi-bin/fzf_surfraw.cgi6
-rwxr-xr-x.w3m/cgi-bin/fzf_surfraw_tmux.cgi41
-rwxr-xr-x.w3m/cgi-bin/goto_clipboard.cgi25
-rwxr-xr-x.w3m/cgi-bin/goto_clipboard_primary.cgi28
-rwxr-xr-x.w3m/cgi-bin/goto_tmux_clipboard.cgi28
-rwxr-xr-x.w3m/cgi-bin/restore_session.cgi49
-rwxr-xr-x.w3m/cgi-bin/restore_tab.cgi10
7 files changed, 187 insertions, 0 deletions
diff --git a/.w3m/cgi-bin/fzf_surfraw.cgi b/.w3m/cgi-bin/fzf_surfraw.cgi
new file mode 100755
index 0000000..de297c1
--- /dev/null
+++ b/.w3m/cgi-bin/fzf_surfraw.cgi
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOVAL'| fzf --algo=v2 -e | awk '{print $1}')
+if [ "$PREFIX" = "" ]; then exit;fi
+read -r -e -p " $PREFIX >>> Enter The Search Keyword: " INPUT
+surfraw -p "$PREFIX" "$INPUT" | xsel -p
diff --git a/.w3m/cgi-bin/fzf_surfraw_tmux.cgi b/.w3m/cgi-bin/fzf_surfraw_tmux.cgi
new file mode 100755
index 0000000..11516fd
--- /dev/null
+++ b/.w3m/cgi-bin/fzf_surfraw_tmux.cgi
@@ -0,0 +1,41 @@
+#!/usr/bin/env sh
+### _ _ _ _
+### __ _ ___ | |_| |__ | | ___| |_ _ _
+### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
+###| (_| | (_) | |_| |_) | | __/ |_| |_| |
+### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
+### |___/
+### https://www.youtube.com/user/gotbletu
+### https://lbry.tv/@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 -p "$PREFIX" "$INPUT" | xsel -p
+pidof tmux >/dev/null && tmux set-buffer "$(surfraw -p "$PREFIX" "$INPUT")"
diff --git a/.w3m/cgi-bin/goto_clipboard.cgi b/.w3m/cgi-bin/goto_clipboard.cgi
new file mode 100755
index 0000000..34eaa63
--- /dev/null
+++ b/.w3m/cgi-bin/goto_clipboard.cgi
@@ -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"
diff --git a/.w3m/cgi-bin/goto_clipboard_primary.cgi b/.w3m/cgi-bin/goto_clipboard_primary.cgi
new file mode 100755
index 0000000..a9b208e
--- /dev/null
+++ b/.w3m/cgi-bin/goto_clipboard_primary.cgi
@@ -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"
diff --git a/.w3m/cgi-bin/goto_tmux_clipboard.cgi b/.w3m/cgi-bin/goto_tmux_clipboard.cgi
new file mode 100755
index 0000000..fe91b57
--- /dev/null
+++ b/.w3m/cgi-bin/goto_tmux_clipboard.cgi
@@ -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"
diff --git a/.w3m/cgi-bin/restore_session.cgi b/.w3m/cgi-bin/restore_session.cgi
new file mode 100755
index 0000000..aa0ba41
--- /dev/null
+++ b/.w3m/cgi-bin/restore_session.cgi
@@ -0,0 +1,49 @@
+#!/usr/bin/env sh
+# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
+# https://www.youtube.com/user/gotbletu
+# DESC: generate a script for your last w3m session then you can run script to restore all urls in new tabs
+# DEMO: https://youtu.be/qYhNJ3itqWw
+# DEPEND: coreutils gawk
+# CLOG: 2021-04-17 first draft, no option to jump to tab 1 at the moment
+# REQD: 1. Allow executable permissions and put script in ~/.w3m/cgi-bin/restore_session.cgi
+#
+# 2. Add binding to ~/.w3m/keymap
+#
+# ############################ Quit with confirmation request (QUIT)
+# keymap :q QUIT
+# keymap ZZ QUIT
+# ############################ Quit at once (EXIT)
+# keymap ZQ EXIT
+# ############################ Quit at once and save session
+# keymap Q COMMAND "EXTERN 'echo %s > ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; NEXT_TAB ; EXTERN 'echo %s >> ~/.w3m/RestoreSession.txt' ; READ_SHELL ~/.w3m/cgi-bin/restore_session.cgi ; EXIT"
+#
+# 3. Add to ~/.bashrc or ~/.zshrc $PATH variable
+# [ -d "$HOME/.w3m/bin" ] && PATH="$HOME/.w3m/bin:$PATH"
+#
+# 4. To load w3m with the last session
+# $ w3mlastsession
+
+## ---------------------------------------------
+mkdir -p "$HOME/.w3m/bin"
+# location of generated script of last session
+RESTORE_SESSSION="$HOME/.w3m/bin/w3mlastsession"
+# add shell header
+echo "#!/usr/bin/env sh" > "$RESTORE_SESSSION"
+echo "torsocks w3m -graph \\" >> "$RESTORE_SESSSION"
+# remove dupes without sorting, add -N flag at beginning and append trailing slash to each url
+awk '!x[$0]++' "$HOME/.w3m/RestoreSession.txt" | while read -r line ; do echo "-N '$line' \\" >> "$RESTORE_SESSSION" ; done
+echo "2>/dev/null" >> "$RESTORE_SESSSION"
+chmod +x "$RESTORE_SESSSION"
+
+## OUTPUT SCRIPT FILE EXAMPLE ~/.w3m/bin/w3mlastsession
+## --------------------------------------------------
+## #!/usr/bin/env sh
+## w3m \
+## -N 'https://www.reddit.com/r/w3m/.mobile' \
+## -N 'https://www.reddit.com/r/commandline/.mobile' \
+## -N 'https://www.reddit.com/r/linux/.mobile' \
+## -N 'http://lite.cnn.com/en' \
+## -N 'https://raw.githubusercontent.com/tats/w3m/master/ChangeLog' \
+## -N 'https://github.com/gotbletu/shownotes' \
+## 2>/dev/null
+## --------------------------------------------------
diff --git a/.w3m/cgi-bin/restore_tab.cgi b/.w3m/cgi-bin/restore_tab.cgi
new file mode 100755
index 0000000..27b3316
--- /dev/null
+++ b/.w3m/cgi-bin/restore_tab.cgi
@@ -0,0 +1,10 @@
+#!/usr/bin/env sh
+
+TAB_RESTORE_LIMIT=30
+
+last_tab=$(tail -n 1 ~/.w3m/RestoreTab.txt);
+limit=$(tail -n $TAB_RESTORE_LIMIT ~/.w3m/RestoreTab.txt)
+other_tabs=$(printf "%s" "$limit" | head -n -1);
+printf "%s\r\n" "$other_tabs" > ~/.w3m/RestoreTab.txt;
+printf "%s\r\n" "W3m-control: GOTO $last_tab";
+printf "W3m-control: DELETE PREVBUF\r\n";