Command the Web - an ELinks tutorial

Command-line browsing is not always the best approach; e.g. for flickr or a webcomic, it is the wrong approach of course.

However, for most things command line browsing works well. The system requirements are very low indeed. It is fast and secure; web pages have a consistent look and there are no flashing adverts, pop up windows or other web annoyances.

About ELinks

ELinks is the coolest command line web browser, indeed it is the only command line web browser that is both still actively developed and supports modern web pages. So as they say where I come from, "it is a good thing you like potatoes". You can think of ELinks as the Firefox at the command line, only cooler and more fun.

http://commandline.org.uk/images/posts/apps/elinks.png

Available from all good Linux/BSD package managers (the package name is normally just elinks). Gentoo users will want to look at the USE Flags carefully and enable everything that you are familiar with, you probably do want Javascript, otherwise many webpages will not work as you expect.

You might want to install it now; then this tutorial is rather more fun. You might want to put your xterm or PuTTy window in one part of the screen and this webpage in the other.

You can just type elinks to start the program, you can also add a domain name, for example:

elinks commandline.org.uk

Basic usage tutorial

Once in the program you use the 'g' key to bring up the address bar (i.e. the 'Go' box). Now you can type in where you want to go.

http://commandline.org.uk/images/posts/apps/elinks2.png

Navigation is pretty obvious. The 'home' key takes you to the top, 'end' to the bottom. Page Up and Down do what they say, you can also just whack the space bar to scroll down through a page. Hit the right cursor key (or Enter) on a hyperlink to follow it, use the left cursor to go backwards. Use the up and down cursor keys to work through the available hyperlinks.

When you want to use a form field or text box, select it with the up and down cursor keys then press Enter to select it for text-entry.

Use the forward slash '/' to search for a word on the page, then use the 'n' key to show the next occurrence.

In rare cases, the webpage might not fit horizontally into your window, in that case use the square brackets [ ] to scroll the page left and right respectively.

Use q to quit and go back to your terminal.

If you haven't already, then you probably want to get used to these basic commands first. When you are comfortable with the interface, then try to use some of the more advanced features outlined below.

Incidentally, if you know Emacs keybindings, many of the basic Emacs movement and navigation commands work in ELinks also. If you want to use a mouse for cut and paste, you need to hold down shift while you select text.

Basic Commands

g - go to URL (bring up address bar)

Home - go to top of page

End - go to bottom of page

Left - go back

Right - follow hyperlink

Up - previous hyperlink

Down - next hyperlink

/ - search

n - next occurrence

[ - scroll window left

] - scroll window right

q - quit

More Commands

d - download hyperlink

ctrl r - refresh

- view HTML

s - bookmarks

h - history

o - options (i.e. browser preferences)

Tabbed Browsing

c close tab

t Open new blank tab

T Open link as tab

< > Move to left/right tab

Alt < Alt > Move tab lef /right

http://commandline.org.uk/images/posts/apps/elinks3.png

URL Shortcuts

ELinks has a URL shortcut feature, you can type special keywords into the 'Go' box (i.e. the address bar) and it will resolve them into URLs. You can define your own shortcuts to your favourite sites, but there are also a number pre-included.

Depending on how the shortcut has been set up, you either type the keyword shortcut alone or you type the keyword shortcut with extra terms (sometimes both). In this latter case, you can type one or extra terms which will be sent as form data in the get request, the significance of these extra terms will vary according to the context.

That last sentence was a long way of saying that you can type 'g fish' and it will search Google for 'fish'.

I decided to contrentrate on these dynamic shortcuts, so in all of the keyword shortcuts featured below, you can at least do it with the keywords, sometimes the keywords are optional.

Top Three Shortcuts

The podium places go to:

g - search google

wiki - lookup a term in the wikipedia

sd - slashdot - popular technical news site

http://commandline.org.uk/images/posts/apps/elinks4.jpg

Dictionaries

There are three dictionaries, and two thesauri.

cambridge - Cambridge Advanced Learner's Dictionary

d - The Collaborative International Dictionary of English

dict - dictionary.reference.com

mw - Merriam-Webster

mwt - Merriam-Webster Thesaurus

thes - thesaurus.reference.com

Open Source software

All the following shortcuts will help you find free and open source software:

dpkg - debian packages

fm - freshmeat

fsd - fsf directory

savannah - Savannah

sf - Sourceforge

More Search

dmoz - open directory

imdb - film search

g - google search

gn - google news

gr - google groups (aka Usenet)

Geeky links

py - Python Documentation

whatis - server uptime etc

vhtml - w3 validator html

vcss - w3 validator css

emacs - emacs Wiki

More Shortcuts

That is enough to give you an idea of the power of elinks' shortcut feature. Other miscellaneous shortcuts include:

bb - use the babelfish translator

arc - use the Internet archive web archive to look up past versions of pages, very useful when you find that you have followed a dead link.

http://commandline.org.uk/images/posts/apps/elinks5.png

Adding a new shortcut

Let's add a new shortcut.

  • Press the 'o' key to open the options window.
  • Scroll down to Protocols and hit space to expand the category.
  • Scroll down to URI rewriting and hit space to expand the category.
  • Scroll down to Dumb Prefixes and hit space to expand the category.
  • Press the right cursor key and select 'Add', press enter.
  • Type clw
  • Press the Enter key
  • Use your cursor keys again to select 'Edit', press enter.
  • Type or paste into the box the following URL: http://commandline.org.uk/#warrior
  • Select Save, press enter
  • Select Close, press enter

Now from the main ELinks window, you can press the 'g' key, type 'clw' and be back here!

Well that's all for now, in a future post I will look at scripting ELinks. Do let me know how you got on using the comments below. Enjoy the command-line web. Surf's Up!

http://commandline.org.uk/images/posts/apps/elinks6.png

13 thoughts on “Command the Web - an ELinks tutorial

  1. <p>Hmmm, I've always found text-based browsing to be a little tedious -
    especially if you have a website like mine (i.e., loads of links appearing at
    the top before you get to the actual content).</p>
    <p>Very useful, though, if you want to browse the web over SSH (which you have
    to do sometimes, i.e. if you're logging into a work PC via SSH and you want
    to do something via a web-based control panel...)</p>

  2. <p>I find the way you can navigate in lynx very enjoyable (I'm sure it's the
    same model for elinks).
    After getting used to INS and DEL for scrolling (I don't see these keys in
    your tutorial?) I immediately mapped them in vim.
    (Because you've got to have something between line-by-line scrolling and page
    scrolling (on a single key!))</p>

  3. <p>Thank you very much for yet another splendid tutorial which enriched my
    modest collection of &quot;cheat-sheets&quot;(together with shortcuts for vim, bash and
    emacs) <img src="/static/forum/img/smilies/wink.png">. Being a fan of simple tools I let myself to add one more tip: to
    import your bookmarks from fi. Firefox to Elinks either convert the format
    from .html to .xbel using CLI(xbel_parse ?) or go to
    <a class="reference external" href="http://www.linkagogo.com/">http://www.linkagogo.com/</a> where you can convert your bookmarks online and
    then move the bookmarks.xbel file into your .elinks directory.
    I'm looking forward to your next tutorials and once again many thanks from
    grateful reader,</p>
    <p>tami</p>

  4. <p>You missed the one key that actually makes elinks usable: . Yes, the period
    key. It turns on link numbers next to each link, so it makes it really easy
    to jump to links. Simply type the number and then enter and you jump to that
    link</p>

  5. <p>Good stuff! I've been using elinks for a little while, but had never really
    delved into it. Never even bothered to learn the shortcuts. Found you from a
    random google search for elinks, and now I'll be using those shortcuts all
    the time. Thanks for taking the time to post.</p>

  6. <p>Now - thanks to this article - I just type &quot;links markets&quot; and I have instant world wide market listings - good thing I work on the first floor ;-)</p>

  7. <p>thanx man
    i need to know how i can download html source page from elinks ?
    i try
    $ elinks - view HTML &quot;<a class="reference external" href="http://www.google.com/">http://www.google.com/</a>&quot; &gt; resulthtml.txt
    but its dont work <img src="/static/forum/img/smilies/sad.png">
    thanx again</p>

  8. <p>i try this line command
    elinks -source &quot;<a class="reference external" href="http://www.e51g.com/">http://www.e51g.com/</a>&quot; &gt; resulthtml.txt</p>
    <p>its work done <img src="/static/forum/img/smilies/smile.png"> thx</p>

  9. <p>Thank you for the great articles! Now, I now how to navigate the www with elinks when there is no broadband available. Keep up the good work.</p>

How about Global Thermonuclear War? Wouldn't you prefer a good game of chess? Powered by zpress