ep

This is an old post from an old blog; assets may be missing, links may be broken, and my opinions may differ considerably by this point…

My reasoning is pretty simple - ELinks is quick enough to work suitably as a pager, and it has scrollwheel support! This is really quite nice, because as much as I love the keyboard, momentum scrolling with a Magic Mouse is a game-changer. So those are the 'whys,' and a quick run of ls | elinks does plenty to demonstrate the 'why nots':

elinks, by default, throws up a mimetype request

So, this isn't desirable in a pager - responding to a modal dialog before seeing the output. A pager should show the text it's supposed to show with no further prompting, and ideally no delay whatsoever. It should be a fairly transparent piece of the command line, really. This is easy to suppress - just run elinks -default-mime-type "text/plaintext" and you're good to go. But then another ugly demon roars its head:

confirm quit? no thank you!

Pressing q is a normal ELinks quit - throwing up a confirmation box. Again, not desirable in a pager. Shiftq quits without confirmation, but in my mind, a pager quits with a bare q. This can't be set with command line arguments, so the process begins…

Fortunately, ELinks lets you choose a custom configuration file by means of the -config-file argument. So step one is to make a custom config file in ~/.elinks called pager.conf. I just copied my elinks.conf to pager.conf and added from there. Additions are as follows:

#bind q to quit without confirmation
 bind "main" "q" = "really-quit"
#set a default mimetype (plaintext)
 set mime.default_type = "text/plaintext"
#get rid of useless bottom status bar (see above)
 set ui.show_status_bar = 0

So that was step one - making a more pager-esque conf file for ELinks to use. Step two is simply making it so that I don't have to type ls | elinks -config-file pager.conf all the time. I use (and love) fish as my shell, which can use traditional aliases, but prefers its own built in function system. So, added to my .fish file is…

function ep -d "Use ELinks as pager"
  elinks -config-file pager.conf $argv
end

…which allows me to use ep (ELinks pager) as an alias to running elinks with the pager.conf file loaded. Other shells (and, technically, fish as well) can achieve this with alias ep=elinks -config-file pager.conf. (I believe. Correct me if I'm wrong, it's been a while.) And with that, you have ls | ep for a nice, scroll-wheel-friendly pager. One unfortunate reality is that behavior is more like more than like less - the whole stdin needs to be read before the display is rendered. For very large listings, this is… unpleasant at best.


•