w3m code update READ_SHELL

pull/41/head
gotbletu 3 years ago
parent af455a5092
commit a06ddea607

@ -15,10 +15,11 @@ Given a html document, it pulls out the main body text and cleans it up.
keymap L NEXT keymap L NEXT
keymap H PREV keymap H PREV
keymap \\\R COMMAND "SHELL 'python3 -m readability.readability -u $W3M_URL > /tmp/readability.html' ; LOAD /tmp/readability.html" keymap \\\r COMMAND "READ_SHELL 'python3 -m readability.readability -u $W3M_URL 2> /dev/null 1> /tmp/readability.html' ; LOAD /tmp/readability.html"
### usage ### usage
press \R on a webpage while running w3m web browser press \r on a webpage while running w3m web browser
### references ### references
- W3M playlist https://www.youtube.com/playlist?list=PLqv94xWU9zZ35Yv0s6zMID5JoS8qu19Kh - W3M playlist https://www.youtube.com/playlist?list=PLqv94xWU9zZ35Yv0s6zMID5JoS8qu19Kh

@ -13,7 +13,8 @@ readability-cli (aka readable) takes any HTML page and strips out unnecessary bl
keymap L NEXT keymap L NEXT
keymap H PREV keymap H PREV
keymap \\\r COMMAND "SHELL 'readable $W3M_URL -p html-title,html-content > /tmp/readable.html' ; LOAD /tmp/readable.html" keymap \\\r COMMAND "READ_SHELL 'readable $W3M_URL -p html-title,html-content > /tmp/readable.html' ; LOAD /tmp/readable.html"
### usage ### usage
press \r on a webpage while running w3m web browser press \r on a webpage while running w3m web browser

@ -7,13 +7,27 @@ Text-to-speech engine used on Android phones. Works on linux also.
aur/svox-pico-bin # archlinux aur/svox-pico-bin # archlinux
libttspico-utils # ubuntu / debian libttspico-utils # ubuntu / debian
picospeaker # https://gitlab.com/ky1e/picospeaker picospeaker # https://gitlab.com/ky1e/picospeaker
toggle-process.zsh # https://github.com/chimay/scripts/blob/master/zsh/toggle-process.zsh
rdrview # https://github.com/eafer/rdrview
### configuration ### configuration
vim ~/.w3m/keymap vim ~/.w3m/keymap
keymap \\\s COMMAND "SHELL 'picospeaker $W3M_CURRENT_WORD 2>/dev/null'" # say current word
keymap \\\s COMMAND "READ_SHELL 'picospeaker $W3M_CURRENT_WORD 2>/dev/null' ; BACK"
# read current page
keymap \\\a COMMAND "PRINT /tmp/picospeaker.txt ; SHELL 'picospeaker < /tmp/picospeaker.txt 2>/dev/null &'" keymap \\\a COMMAND "PRINT /tmp/picospeaker.txt ; SHELL 'picospeaker < /tmp/picospeaker.txt 2>/dev/null &'"
keymap \\\k COMMAND "SHELL 'killall play'"
# strip junk from current page and read current page
keymap \\\R COMMAND "READ_SHELL 'rdrview -H $W3M_URL 2> /dev/null 1> /tmp/rdrview.html' ; LOAD /tmp/rdrview.html ; PRINT /tmp/picospeaker.txt ; SHELL 'picospeaker < /tmp/picospeaker.txt 2>/dev/null &'"
# stop current text to speech process
keymap \\\k COMMAND "READ_SHELL 'killall play' ; BACK"
# toggle (pause/play) current text to speech process
keymap \\\p COMMAND "READ_SHELL 'toggle-process.zsh /usr/bin/play' ; BACK"
### usage ### usage
press \a on a webpage for the pico tts program to read it aloud press \a on a webpage for the pico tts program to read it aloud
@ -24,6 +38,7 @@ Text-to-speech engine used on Android phones. Works on linux also.
- https://aur.archlinux.org/packages/svox-pico-bin/ - https://aur.archlinux.org/packages/svox-pico-bin/
- https://android.googlesource.com/platform/external/svox/+/master - https://android.googlesource.com/platform/external/svox/+/master
- https://youtu.be/BijKHsvOvxc - https://youtu.be/BijKHsvOvxc
- https://github.com/chimay/scripts/blob/master/zsh/toggle-process.zsh
### contact ### contact

@ -25,7 +25,9 @@ Using macros automate toggling settings like images display or table borders on
### references ### references
- https://youtu.be/lL73xWsaJP8 - https://youtu.be/lL73xWsaJP8
- https://raw.githubusercontent.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m/master/documentation/functions.txt - https://raw.githubusercontent.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m/master/documentation/functions.txt
- https://ntmlabs.com/w3m-tricks/ - https://vitalyparnas.com/posts/2018/08/on-w3m/
- https://vitalyparnas.com/posts/2019/07/w3m-redux/
- https://vitalyparnas.com/guides/w3m/
- https://developers.whatismybrowser.com/useragents/explore/ - https://developers.whatismybrowser.com/useragents/explore/
- [W3M Playlist](https://www.youtube.com/playlist?list=PLqv94xWU9zZ35Yv0s6zMID5JoS8qu19Kh) - [W3M Playlist](https://www.youtube.com/playlist?list=PLqv94xWU9zZ35Yv0s6zMID5JoS8qu19Kh)

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) # AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
# https://www.youtube.com/user/gotbletu # https://www.youtube.com/user/gotbletu
# DESC: interactive surfraw smart prefix search engine # DESC: interactive surfraw smart prefix search engine
@ -8,43 +8,46 @@
# 2. allow permissions and put fzf_surfraw.cgi any where you like e.g ~/.w3m/cgi-bin/ # 2. allow permissions and put fzf_surfraw.cgi any where you like e.g ~/.w3m/cgi-bin/
# 3. $EDITOR ~/.w3m/keymap # 3. $EDITOR ~/.w3m/keymap
# #
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi" # # for x session
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi" # keymap xs COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi ; REDRAW"
# # keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi" # keymap XS COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; BACK ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi ; REDRAW"
# # keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi" # # for tmux users
# # keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi" # # keymap xs COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi ; REDRAW"
# # keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi" # # keymap XS COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi; BACK ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi ; REDRAW"
#
# CLOG: 2021-02-05 version 0.3 copy to all 3 clipboard at once; xsel primary/system clipboard, tmux clipboard
# CLOG: 2021-04-11 version 0.4 remove read command for posix compatible (good idea by https://github.com/NapoleonWils0n)
# new keymap use READ_SHELL and tmux load-buffer to avoid unnecessary prompt
# 2021-02-05 version 0.3 copy to all 3 clipboard at once; xsel primary/system clipboard, tmux clipboard
# 2020-05-08 version 0.2 surfraw -p instead of echo # 2020-05-08 version 0.2 surfraw -p instead of echo
# 2020-04-27 version 0.1 # 2020-04-27 version 0.1
# clear screen # clear screen
printf "\033c" printf "\033c"
# select your elvi # select your elvi
PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e | awk '{print $1}') # PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL'| fzf -e | awk '{print $1}')
PREFIX=$(surfraw -elvi | grep -v 'LOCAL\|GLOBAL' | fzf -e --prompt='Pick search engine: ' --info=inline --layout=reverse | awk '{print $1}')
# exit script if no elvi is selected (e.g hit ESC) # exit script if no elvi is selected (e.g hit ESC)
# if [ "$PREFIX" = "" ]; then exit; fi # if [ "$PREFIX" = "" ]; then exit; fi
[ -z "$PREFIX" ] && exit [ -z "$PREFIX" ] && exit
# get user input # get user input
read -r -e -p " $PREFIX >> Enter Your Search Keyword: " INPUT # read -r -e -p " $PREFIX >> Enter Your Search Keyword: " INPUT
INPUT=$(printf | fzf --print-query --prompt="Enter keyword(s) to search ${PREFIX}: " --info=inline --layout=reverse)
# print proper url and copy to primary clipboard (aka highlighted clipboard) and tmux clipboard # print proper url and copy to primary clipboard (aka highlighted clipboard) and tmux clipboard
# surfraw -p "$PREFIX" "$INPUT" | xsel -p
# tmux set-buffer "$(surfraw -p "$PREFIX" "$INPUT")"
# note: dont quote $INPUT it will mess up results # note: dont quote $INPUT it will mess up results
# -------------------------------
# copy to xsel primary (aka shift-insert) # copy to xsel primary (aka shift-insert)
surfraw -p "$PREFIX" $INPUT | xsel -p surfraw -p "$PREFIX" $INPUT | xsel -p
# copy to xsel system clipboard (aka ctrl-v) # copy to xsel system clipboard (aka ctrl-v)
surfraw -p "$PREFIX" $INPUT | xsel -b # surfraw -p "$PREFIX" $INPUT | xsel -b
# copy to tmux clipboard # copy to tmux clipboard
tmux set-buffer "$(surfraw -p "$PREFIX" $INPUT)" # tmux set-buffer "$(surfraw -p "$PREFIX" $INPUT)"
# pidof tmux >/dev/null && tmux set-buffer "$(surfraw -p "$PREFIX" "$INPUT")" # pidof tmux >/dev/null && tmux set-buffer "$(surfraw -p "$PREFIX" "$INPUT")"
surfraw -p "$PREFIX" $INPUT | tmux load-buffer -

@ -35,21 +35,20 @@ Download at [cgi-bin](w3m_plugins/cgi-bin)
vim ~/.w3m/keymap vim ~/.w3m/keymap
# for x sessions # 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 "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi ; REDRAW"
keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi" keymap XS COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; BACK ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard_primary.cgi ; REDRAW"
# 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 # for tmux users
# keymap xs COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi" # keymap xs COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi ; GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi ; REDRAW"
# keymap XS COMMAND "SHELL ~/.w3m/cgi-bin/fzf_surfraw_tmux.cgi ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi" # keymap XS COMMAND "READ_SHELL ~/.w3m/cgi-bin/fzf_surfraw.cgi; BACK ; TAB_GOTO /usr/lib/w3m/cgi-bin/goto_tmux_clipboard.cgi ; REDRAW"
### set the default open-url to current url ### set the default open-url to current url
sed -i 's:default_url.*:default_url 1:g' ~/.w3m/config sed -i 's:default_url.*:default_url 1:g' ~/.w3m/config
### usage example ### usage example
$ w3m google.com $ w3m google.com
then press XS to use surfraw for smart search then press xs or XS to use surfraw for smart search
### references ### references
- https://youtu.be/0j3pUfZjCeQ - https://youtu.be/0j3pUfZjCeQ

Loading…
Cancel
Save