Space Panda

Fancy Mail Listing

This is the third part in the series on Reading Mail in the Terminal.

By default (neo)mutt will list emails rather bluntly like this:

The default mail listing of neomutt.

This is what the default view of an inbox looks like. There is some quick help on top, the emails are sorted by date, the most recent at the bottom. You can see the date, sender, size, and subject of each mail. Yes, it’s all spam.

The first step is to change the sorting to go by date of arrival and have the most recent mail at the top:

# ~/.config/neomutt/neomuttrc

set sort=reverse-date-received

Better yet, if you want to see replies as threads, you can set sort to reverse-threaded. See sort for all options.

Now let’s change the way the mails are listed. The variable for that is called index_format. Suppose you want to see the status of the email (is it new, replied to, marked for deletion, has attachments?), the subject, who it sent and when it arrived, and all of that in this order, the configuration would look like this:

# ~/.config/neomutt/neomuttrc

set index_format="%4C %?X?@& ?%S %.70s %> %L %D"

The format string piece by piece:

  • %4C – reserve 4 characters for the index

  • %?X?@& ? – if %X (the number of MIME attachments) is bigger than 0, show the @ sign, otherwise not. That’s close enough to a paper clip.

  • %S – the status of an email (r means you wrote a reply, N means it’s new, O stands for “not exactly new, but you didn’t read it yet”, etc.)

  • %.70s – use up to 70 characters to show the subject

  • %> – right align the rest of this line

  • %L – the sender

  • %D – date and time of the message

I’m not a fan of the help line on the top, so let’s replace it with some status information about the currently open mailbox:

# ~/.config/neomutt/neomuttrc

# disable the help display
set help = no

# move the status bar to the top
set status_on_top = yes

# and show some useful status information there
set status_format = " %u new mail%?p? - %p drafts&?%?F? - %F important mail&? %> %m "

Again, a walk-through for status_format, because it’s a real mess:

  • %u new mail – that’s the number of new emails in this mailbox. When you look in the screenshot you can see that mail 7 is new, is has the N status.

  • %?p? - %p drafts&? – if there are any postponed emails (%p is not 0), this will show their number here.

  • %?F? - %F important mail&? – you can flag emails, which usually means they are important. See email 8 for example, it is flagged and therefore the status shows a !.

  • %> – the rest of the line will be right aligned

  • %m – that’s just the number of emails in this mailbox

Neomutt mail listing with the improved index_format.

With the status on top and the new index_format (neo)mutt looks already much more inviting. Mail 1 has been replied to, mail 2 through 6 have attachments, mail 6 is marked for deletion, mail 7 is new, and mail 8 is flagged as important.

Use of Nerd Fonts

At this point it really pays off to use the Nerd Fonts in your terminal, because you can replace the @ with an actual paperclip and the status characters with corresponding icons.

And the email status character is also configurable through the flag_chars:

# ~/.config/neomutt/neomuttrc

set index_format  = "%4C %?X?& ?%S %.70s %> %L %D"
set flag_chars    = "d  "
set status_format = "  %u %?p?  %p&?%?F?   %F&? %>  %m "
Neomutt mail listing with nerd font icons.

With Nerd Fonts the listing is much more expressive. The status bar has fancy separators and icons to indicate how many new mails, drafts, and important emails there are. The status icons are also much more readable.

The next article discusses customisations for displaying mail.

Tagged as mail, neomutt, nerdfonts