Part Three: Mutt and Elinks

You have your terminal ‘desktop’. Multiple ‘windows’, status indicators, even a clock in the corner. In order to be a truly useable desktop, you need an email client, and a web browser.

Even if you’re not living in the terminal, having access to a basic web browser can also be handy for simple things, like checking the status of web apps on a server before they’re public, or googling a snippet of info when your X11 configuration has broken.

Whatever your reasons, I recommend to you: Mutt and Elinks.

Mutt

Handling email is something that terminal applications can actually be quite good at - there have been such programs around for many decades. Even HTML emails are viewable! Though of course you’ll have to do without images.

I recommend mutt, a no-nonsense, configurable (seeing a pattern with these?) terminal email client. With a small amount of configuring, you can have an intuitive list of emails that you can view one at a time, and reply to with vim or other text editor.

Mutt inbox view, running in a byobu tab

Here is a basic .muttrc file (with a pretty colour theme) to get you going:

Click to expand:

# Auto connect to an IMAP server of your choosing
set spoolfile="+INBOX"
set folder="imaps://your.email.server/"
set record="=Sent"
set postponed="=Drafts"
set timeout=20
set mail_check=20
set mbox="=INBOX"
set sort=reverse-date

# Render HTML emails properly
auto_view text/html

# Return from other folders to inbox with '.'
macro index . "<change-folder>=INBOX<enter>" "Inbox"

# Solarized dark theme from https://github.com/altercation/mutt-colors-solarized
#
# basic colors ---------------------------------------------------------
color normal        color241        color234        
color error         color160        color234        
color tilde         color235        color234        
color message       color37         color234        
color markers       color160        color254        
color attachment    color254        color234        
color search        color61         color234        
color status        color241        color235        
color indicator     color234        color136        
color tree          color136        color234   # arrow in threads

# basic monocolor screen
mono  bold          bold
mono  underline     underline
mono  indicator     reverse
mono  error         bold

# index ----------------------------------------------------------------
# deleted
color index         color160        color234        "~D(!~p|~p)"  
# flagged
color index         color235        color234        ~F
# duplicate messages
color index         color166        color234        ~=            
# all messages
color index         color160        color234        "~A"          
# expired messages
color index         color166        color234        "~E"          
# new messages
color index         color33         color234        "~N"          
# old messages
color index         color33         color234        "~O"          
# messages that have been replied to
color index         color61         color234        "~Q"          
# read messages
color index         color240        color234        "~R"          
# unread messages
color index         color33         color234        "~U"          
# unread, unreferenced messages
color index         color33         color234        "~U~$"        
# messages part of a collapsed thread
color index         color241        color234        "~v"          
# messages from me
color index         color241        color234        "~P"          
# messages to me
color index         color37         color234        "~p!~F"       
# new messages to me
color index         color37         color234        "~N~p!~F"     
# unread messages to me
color index         color37         color234        "~U~p!~F"     
# messages to me
color index         color240        color234        "~R~p!~F"     
# flagged messages
color index         color160        color234        "~F"          
# flagged messages to me
color index         color160        color234        "~F~p"        
# new flagged messages
color index         color160        color234        "~N~F"        
# new flagged messages to me
color index         color160        color234        "~N~F~p"      
# new flagged messages to me
color index         color160        color234        "~U~F~p"      
# deleted messages
color index         color235        color160        "~D"          
# collapsed thread with no unread
color index         color245        color234        "~v~(!~N)"    
# collapsed thread with some unread
color index         color136        color234        "~v~(~N)"     
# collapsed thread with unread parent
color index         color64         color234        "~N~v~(~N)"   

# statusbg used to indicated flagged when foreground color shows other status
# for collapsed thread

# collapsed thread with flagged, no unread
color index         color160        color235        "~v~(~F)!~N"  
# collapsed thread with some unread & flagged
color index         color136        color235        "~v~(~F~N)"   
# collapsed thread with unread parent & flagged
color index         color64         color235        "~N~v~(~F~N)" 
# collapsed thread with unread parent, no unread inside, but some flagged
color index         color64         color235        "~N~v~(~F)"   
# collapsed thread with unread parent, no unread inside, some to me directly
color index         color37         color235        "~v~(~p)"     
# thread with deleted (doesn't differentiate between all or partial)
color index         color136        color160        "~v~(~D)"     
# messages in threads with some unread
color index         color136        color234        "~(~N)"       

# superseded messages
color index         color64         color234        "~S"          
# tagged messages
color index         color160        color234        "~T"          
# duplicated messages
color index         color166        color160        "~="          

# message headers ------------------------------------------------------
color header        color240        color234        "^"
color hdrdefault    color240        color234        
color header        color241        color234        "^(From)"
color header        color33         color234        "^(Subject)"

# body -----------------------------------------------------------------
color quoted        color33         color234        
color quoted1       color37         color234        
color quoted2       color136        color234        
color quoted3       color160        color234        
color quoted4       color166        color234        

color signature     color240        color234        
color bold          color235        color234        
color underline     color235        color234        
color normal        color244        color234        
#
color body          color245        color234        "[;:][-o][)/(|]"    # emoticons
color body          color245        color234        "[;:][)(|]"         # emoticons
color body          color245        color234        "[*]?((N)?ACK|CU|LOL|SCNR|BRB|BTW|CWYL|\
                                                     |FWIW|vbg|GD&R|HTH|HTHBE|IMHO|IMNSHO|\
                                                     |IRL|RTFM|ROTFL|ROFL|YMMV)[*]?"
color body          color245        color234        "[ ][*][^*]*[*][ ]?" # more emoticon?
color body          color245        color234        "[ ]?[*][^*]*[*][ ]" # more emoticon?

## pgp

color body          color160        color234        "(BAD signature)"
color body          color37         color234        "(Good signature)"
color body          color234        color234        "^gpg: Good signature .*"
color body          color241        color234        "^gpg: "
color body          color241        color160        "^gpg: BAD signature from.*"
mono  body          bold                            "^gpg: Good signature"
mono  body          bold                            "^gpg: BAD signature from.*"

# yes, an insane URL regex
color body          color160        color234        "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]"

# Border lines.
color body          color33         color234        "( *[-+=#*~_]){6,}"

You will also want a ~/.mailcap file, which specifies what to do with the auto_view options in your muttrc. Here is one that matches the example above - teling mutt to use elinks to parse HTML emails:

text/html; elinks -dump -dump-charset utf-8 -default-mime-type text/html %s; needsterminal; copiousoutput;

Then go ahead and run mutt. Like vim, you can navigate with j and k or the arrow keys/PgUp/PgDown. Enter shows the highlighted message, and i returns to the index. Other keyboard shortcuts for mutt are displayed at the top of the program, and of course you can press ? to see the full list.

I’ll break it to you now: Large swathes of the web just don’t display well rendered in text. Large swathes of the web don’t function properly without Javascript. Having said that, searching for information on how to fix a system with only a terminal and an internet connection (to use a real-life example) is surprisingly effective given the constraints.

Elinks showing a Google search, running in a byobu tab

You can find elinks in your package manager. Run elinks and after the first-run message, you’ll see a simple URL dialogue box.

This is the equivalent of an address bar, but it also supports shorthand for searching something (e.g. monospace fonts) on Google: g monospace fonts. Pressing . will give each link a number, and you can type that number and press enter to follow it. t makes a new tab, < and > switch tabs, g brings up the address box again. ? shows the rest of the commands.