You are not logged in.
Pages: 1
As far as I know, there is no active thread dealing with w3m or any other text based browser. So I intend to create a common thread to discuss/share tips & trics among users of w3m.
To set the ball rolling, let me write down few trics I am using.
1) to play videos (youtube) using MPV, I have set mpv as my 3rd external browser in options (after qutebrowser and chromium).
So, whenever I want to play a video, I use "3M" to open link with my 3rd external browser. (M is command bound to external browser).
2) I have created few short scripts,
w3d -->
#!/bin/bash
X="$1+$2+$3+$4"
w3m https://duckduckgo.com/?q="$X"
so I can search using "w3d <search term/s>
w3w --> similarly to search wikipedia
w3b --> aliased to "w3m -B" to display bookmarks
Arch is home!
https://github.com/Docbroke
Offline
For your search, just use w3m as your browser in surfraw...
Offline
For your search, just use w3m as your browser in surfraw...
Nice tip! I didn't knew that such thing exists! After adding w3m in surfraw config & adding /usr/lib/surfraw in default path, it is just matter of typing "aur telegram" or "archwiki mutt".
Arch is home!
https://github.com/Docbroke
Offline
I recently at last confured mutt to read html email with the help of w3m:
bing different
Offline
I recently at last confured mutt to read html email with the help of w3m:
What is htmail-view? couldn't find it.
Arch is home!
https://github.com/Docbroke
Offline
Also why 4 parameters in the search? And why an intermediate variable. What you have would be equivalent to
w3m https://duckduckgo.com/?q="$1+$2+$3+$4"
But why require 4 and exactly 4 search terms? Just use whatever is provided:
x=$@
w3m "https://duckduckgo.com/?q=${x// /+}"
I think there is a way to directly replace on the $@ array, but it's elluding me at the moment.
The following could work, it saves a line, but opens a subshell and calls another binary:
w3m https://duckduckgo.com/?q=$(printf "%s+" $@ | head -c -1)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
nbd wrote:I recently at last confured mutt to read html email with the help of w3m:
What is htmail-view? couldn't find it.
I cited the link that I found and used for configuring mutt to use w3m. Didn't hear about htmail-view either.
bing different
Offline
@Trilby, Cause I am linux beginner with limited knowledge, but I keep learning. Thanks for better solution.
4 search term, cause I think I won't need more than 4
Arch is home!
https://github.com/Docbroke
Offline
I just found dmenu based search script "boosta" on github and did some modification for use with w3m, so here it is
script for searching with duckduckgo
#!/bin/bash
LAUNCHER='rofi -dmenu -p Search_Duckduckgo:'
BROWSER='sakura -e w3d'
url=`cat /dev/null | $LAUNCHER | awk -F '|' '{printf("%s ", $NF)}' | tr -d '\r\n'`
if [ ${#url} -gt 0 ]
then
$BROWSER $url
fi
requires another script w3d
cat bin/w3d
#!/bin/bash
x=$@
w3m "https://duckduckgo.com/?q=${x// /+}"
Script can be modified for use with any other broswer. sakura can be replaced with any other terminal of choice, and "rofi -dmenu" with "dmenu"
Another script for using bookmarks with dmenu/rofi
#!/bin/bash
LAUNCHER='rofi -dmenu -location 1 -lines 10 -width 100 -p Bookmarks:'
BROWSER='sakura -e w3m'
BOOKMARKS="$HOME/.w3m/bookmarks"
url=`cat $BOOKMARKS | $LAUNCHER | awk -F '|' '{printf("%s ", $NF)}' | tr -d '\r\n'`
if [ ${#url} -gt 0 ]
then
$BROWSER $url
fi
this script requires bookmarks file(text), with one url per line.
Arch is home!
https://github.com/Docbroke
Offline
did some more editing and now this is "ooh nice", with below given script I can use/search native bookmarks and history files of w3m through dmenu/rofi, just like with uzbl.
#!/bin/bash
grep -o 'http[^"]*' .w3m/bookmark.html > /tmp/bookmarks
cat .w3m/history >> /tmp/bookmarks
LAUNCHER='rofi -dmenu -location 1 -lines 10 -width 100 -p Bookmarks:'
BROWSER='sakura -e w3m'
BOOKMARKS="/tmp/bookmarks"
url=`cat $BOOKMARKS | $LAUNCHER | awk -F '|' '{printf("%s ", $NF)}' | tr -d '\r\n'`
if [ ${#url} -gt 0 ]
then
$BROWSER $url
fi
Last edited by Docbroke (2016-06-04 01:56:03)
Arch is home!
https://github.com/Docbroke
Offline
here is updated script, it opens bookmars & history, opens urls, & if search term is not present in bookmarks/history or it is not a url it will be searched using duckduckgo
#!/bin/bash
grep -o 'http[^"]*' .w3m/bookmark.html > /tmp/bookmarks
grep -o 'http[^"]*' .w3m/history >> /tmp/bookmarks
cat /tmp/bookmarks | rofi -dmenu -location 6 -lines 10 -width 100 -p W3M: > /tmp/x
check=$(cat /tmp/x | wc -l)
(( check == 0)) && exit
grep -o http /tmp/x && sakura -e w3m $(cat /tmp/x) && exit
grep -o "www\." /tmp/x && sakura -e w3m $(cat /tmp/x) && exit
grep -o "\.com" /tmp/x && sakura -e w3m $(cat /tmp/x) && exit
grep -o "\.in" /tmp/x && sakura -e w3m $(cat /tmp/x) && exit
grep -o "\.org" /tmp/x && sakura -e w3m $(cat /tmp/x) && exit
sakura -e w3d $(cat /tmp/x)
only thing that I am not able to solve yet is if search term is present in bookmarks there is no way to search it using duckduckgo.
so if I want to search "duck" I cannot as duckduckgo is there in bookmarks
Arch is home!
https://github.com/Docbroke
Offline
here is updated script, it opens bookmars & history, opens urls, & if search term is not present in bookmarks/history or it is not a url it will be searched using duckduckgo
script w3d is posted above
#!/bin/bash
grep -o 'http[^"]*' .w3m/bookmark.html > /tmp/bookmarks
grep -o 'http[^"]*' .w3m/history >> /tmp/bookmarks
cat /tmp/bookmarks | rofi -dmenu -location 6 -lines 10 -width 100 -p W3M: > /tmp/x
check=$(wc -l < /tmp/x)
(( check == 0)) && exit
grep -o http /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "www\." /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.com" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.in" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.org" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
sakura -e w3d $(< /tmp/x)
only thing that I am not able to solve yet is if search term is present in bookmarks there is no way to search it using duckduckgo.
so if I want to search "duck" I cannot as duckduckgo is there in bookmarks
EDIT: just spared all the cats, as suggested by jwr, now feline-lovers can rest in piece!
Last edited by Docbroke (2016-06-09 04:03:09)
Arch is home!
https://github.com/Docbroke
Offline
That cat only has one more life!
$( </tmp/x)
Offline
Offline
further update, now using surfraw for searching various sites, (not added all surfraw scripts as I don't need them all)
example to search life of pie on imdb use "imdb life of pie" as your search term in dmenu
#!/bin/bash
## requires surfraw, w3m, sakura, dmenu/rofi aliased to dmenu
## add below to your .bashrc, (required to search with surfraw)
## PATH=/usr/lib/surfraw:${PATH}
grep -o 'http[^"]*' .w3m/bookmark.html > /tmp/bookmarks
grep -o 'http[^"]*' .w3m/history >> /tmp/bookmarks
cat /tmp/bookmarks | dmenu -location 6 -lines 10 -width 100 -p 'W3M:' > /tmp/x
check=$(wc -l < /tmp/x)
(( check == 0)) && exit
awk '{ print $1 }' /tmp/x > /tmp/y
awk '{ print $2, $3, $4, $5, $6, $7, $8 }' /tmp/x > /tmp/z
grep -o http /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "www\." /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.com" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.in" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.org" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
grep -o "\.edu" /tmp/x && sakura -e w3m $(< /tmp/x) && exit
....
grep -o wiki /tmp/y && sakura -e wikipedia $(< /tmp/z) && exit
grep -o imdb /tmp/y && sakura -e imdb $(< /tmp/z) && exit
grep -o aur /tmp/y && sakura -e aur $(< /tmp/z) && exit
grep -o aw /tmp/y && sakura -e archwiki $(< /tmp/z) && exit
grep -o pkg /tmp/y && sakura -e archpkg $(< /tmp/z) && exit
grep -o google /tmp/y && sakura -e google $(< /tmp/z) && exit
grep -o dict /tmp/y && sakura -e webster $(< /tmp/z) && exit
grep -o dictu /tmp/y && sakura -e urban $(< /tmp/z) && exit
grep -o torrent /tmp/y && sakura -e piratebay $(< /tmp/z) && exit
grep -o pubmed /tmp/y && sakura -e pubmed $(< /tmp/z) && exit
sakura -e S $(< /tmp/x)
Below is a version for GUI browsers, just name your brower in browser=" " line, current default is chromium
#!/bin/bash
## requires surfraw, add below to your .bashrc
## PATH=/usr/lib/surfraw:${PATH}
BROWSER=chromium
grep -o 'http[^"]*' .w3m/bookmark.html > /tmp/bookmarks
grep -o 'http[^"]*' .w3m/history >> /tmp/bookmarks
cat /tmp/bookmarks | rofi -dmenu -location 6 -lines 10 -width 100 -p $BROWSER: > /tmp/x
check=$(wc -l < /tmp/x)
(( check == 0)) && exit
awk '{ print $1 }' /tmp/x > /tmp/y
awk '{ print $2, $3, $4, $5, $6, $7, $8 }' /tmp/x > /tmp/z
grep -o http /tmp/x && $BROWSER $(cat /tmp/x) && exit
grep -o "www\." /tmp/x && $BROWSER $(cat /tmp/x) && exit
grep -o "\.com" /tmp/x && $BROWSER $(cat /tmp/x) && exit
grep -o "\.in" /tmp/x && $BROWSER $(cat /tmp/x) && exit
grep -o "\.org" /tmp/x && $BROWSER $(cat /tmp/x) && exit
grep -o wiki /tmp/y && wikipedia -browser=$BROWSER $(< /tmp/z) && exit
grep -o imdb /tmp/y && imdb -browser=$BROWSER $(< /tmp/z) && exit
grep -o aur /tmp/y && aur -browser=$BROWSER $(< /tmp/z) && exit
grep -o aw /tmp/y && archwiki -browser=$BROWSER $(< /tmp/z) && exit
grep -o pkg /tmp/y && archpkg -browser=$BROWSER $(< /tmp/z) && exit
grep -o google /tmp/y && google -browser=$BROWSER $(< /tmp/z) && exit
grep -o dict /tmp/y && webster -browser=$BROWSER $(< /tmp/z) && exit
grep -o dictu /tmp/y && urban -browser=$BROWSER $(< /tmp/z) && exit
grep -o torrent /tmp/y && piratebay -browser=$BROWSER $(< /tmp/z) && exit
grep -o pubmed /tmp/y && pubmed -browser=$BROWSER $(< /tmp/z) && exit
S -browser=$BROWSER $(cat /tmp/x)
Last edited by Docbroke (2016-06-11 05:39:17)
Arch is home!
https://github.com/Docbroke
Offline
another trick to yank page url from w3m
within w3m open options page with "O"
go to external browser, and set "echo %s | xclip -i" as a external browser, if it is first external browser the script will be called when you press "M" within w3m page and will yank the url to clipboard (requires xclip obviously), if it is for example 2nd external browser you have to use "2M' as keyboard shortcut. To yank url under the cursor use "alt-M" or "2-alt-M" depending on number of the external browser you are using.
In similar way one can open magnet links with torrent client or videos with mpv/youtube-dl from withing w3m.
Arch is home!
https://github.com/Docbroke
Offline
Pages: 1