Browsing the web in a terminal
Three text-mode browsers are installed, and they are genuinely different tools rather than three versions of the same one. There is also a feed reader, which is how you keep up with sites without visiting them.
Which browser
w3m- The best default. Renders tables and layout closest to what the page actually looks like, has mouse support in a terminal, and can display inline images if your terminal supports them. Start here.
lynx- The oldest and the most predictable. Renders everything as a single column, which makes it excellent for reading long documents and for scripting.
links2- Middle ground, with a menu bar you can reach by pressing Esc — useful when you cannot remember a keybinding.
w3m
w3m https://shell.shadowsquad.org/ w3m -dump https://example.org/page # print and exit w3m -dump -T text/html file.html # render a local HTML file
- Space / b
- Page down / up.
- Tab
- Next link. Enter follows it.
- U
- Open a URL.
- B
- Back.
- /
- Search in the page, n for the next match.
- s
- The buffer list — w3m keeps every page you have opened.
- a
- Save the link under the cursor to a file.
- q
- Quit, y to confirm.
lynx
lynx https://shell.shadowsquad.org/ lynx -dump -nolist https://example.org/ # clean text, no link footnotes lynx -source https://example.org/ # raw HTML
Arrow keys do the work: Up/Down move between links, Right follows one, Left goes back. g opens a URL, / searches, \ toggles the HTML source, q quits.
lynx -dump is the one to remember. It turns any page into plain text you can pipe into anything:
lynx -dump -nolist https://example.org/news | grep -i release
What works and what does not
Being honest about this saves an hour of confusion. A text browser sends no JavaScript, so:
- Works well: documentation, wikis, mailing list archives, man pages online, news sites' article pages, forums, plain-text-friendly search engines, anything with a feed.
- Works badly or not at all: single-page applications, anything that renders its content client-side, most modern webmail, sites behind a JavaScript bot check.
Cookies and logins do work — w3m and lynx both keep a cookie jar, so sites that use ordinary form logins are usable. Enter a password only over https://, and remember that this is a shared machine: your cookie jar sits in your home directory.
Feeds: newsboat
The efficient way to follow sites from a shell is not to browse them at all. newsboat is an RSS and Atom reader in the same spirit as mutt.
Put your feeds in ~/.newsboat/urls, one per line:
https://lwn.net/headlines/newrss https://news.ycombinator.com/rss https://example.org/blog/feed.xml tech blogs
Anything after the URL is a tag, so you can filter by topic later. Then:
newsboat # start newsboat -x reload # refresh feeds without opening the interface
- r / R
- Reload the selected feed / all feeds.
- Enter
- Open a feed, then an article.
- o
- Open the article in your browser — set that with
browser "w3m %u"in~/.newsboat/config. - n / N
- Next / previous unread.
- A
- Mark the whole feed read.
- /
- Search across articles.
A reload in cron keeps it current without you waiting for it:
0 * * * * /usr/bin/newsboat -x reload >/dev/null 2>&1
Fetching rather than browsing
Half of what people use a browser for is really just retrieving a file:
curl -O https://example.org/file.tar.gz # download, keep the name curl -s https://example.org/api | head -40 # look at an API response wget -c https://example.org/big.iso # resumable download wget -r -np -l2 https://example.org/docs/ # mirror a small doc tree
Both respect your plan's disk allowance in the sense that nothing stops you filling it — check with usage before pulling something large.