Posted by: Garrick | August 6, 2007

Command the Web – an ELinks tutorial via Command Line Warriors.

UNIX

[Command Line Warriors]

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.

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.

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

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

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.

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!

[original post]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: