Categories
Productivity

Taking back email – Part 4: alot and khard

Recently, I decided to revamp my email setup. I don’t really love email, but it’s such an important method of communication that I needed to get it under control. I’m going to put together a several-post guide explaining my reasoning, technical details, and my new email process.

Other posts in this series (all will be linked here as the posts go up:)

Intro

alot is a simple email client that is meant mainly to be a front-end to work with your notmuch email database. alot provides easy ways to view and read your email, to search, and to compose email. Alot does not, however:

  • Receive email (we’re using OfflineIMAP to grab email from the server)
  • Send email (in the next post, I’ll cover using msmtp to handle sending out email)

khard is a command line contacts manager that can read a CardDav-generated contacts directory. I won’t cover too much about khard in this post, other than how it integrates with alot to make it easier to write your emails.

Installing alot and khard

For Arch Linux, both alot and khard are in the Arch User Repository. Use your favorite AUR helper, something like:

packer -S alot khard

Configuring alot

When configuring alot, the documentation will be very helpful for you: alot documentation

Write a configuration file: vim ~/.config/alot/config.

I’ll go ahead and put my entire alot configuration here. I’m editing out my email addresses, but otherwise it is unchanged:

editor_cmd = terminator -T "Alot Compose" -x vim
tabwidth = 2
attachment_prefix = "~/Downloads"
bug_on_exit = true
editor_in_thread = true

[bindings]

up = move up
down = move down
page up = move page up
page down = move page down
j = move down
k = move up
'g g' = move first
G = move last
' ' = move page down
'ctrl d' = move halfpage down
'ctrl u' = move halfpage up
@ = refresh
? = help bindings
I = search tag:inbox AND NOT tag:killed
'#' = taglist
shift tab = bprevious
U = search tag:unread
tab = bnext
\ = prompt 'search '
x = bclose
$ = flush
m = compose
o = prompt 'search '
q = exit
';' = bufferlist
':' = prompt
. = repeat

[[bufferlist]]
    x = close
    enter = open

[[search]]
    enter = untag unread; select
        a = tag archive; untag inbox; untag todo;
        d = retag delete
    & = toggletags killed
    ! = toggletags flagged
    s = toggletags unread
    t = tag todo; untag inbox;
    i = toggletags inbox
    l = retagprompt
    O = refineprompt
    | = refineprompt

[[envelope]]
    a = prompt 'attach ~/'
    y = send
    P = save
    s = 'refine Subject'
    f = prompt 'set From '
    t = 'refine To'
    b = 'refine Bcc'
    c = 'refine Cc'
    S = togglesign
    enter = edit
    'g f' = togglesource

[[taglist]]
    enter = select

[[thread]]
    enter = select
    C = fold *
    E = unfold *
    c = fold
    e = unfold
    < = fold
    > = unfold
    'g f' = togglesource
    H = toggleheaders
    P = print --all --separately --add_tags
    S = save --all
    g = reply --all
    f = tag forwarded; forward
    p = print --add_tags
    n = editnew
    b= bounce
    s = save
    r = tag replied; reply
    | = prompt 'pipeto '

    'g j' = move next sibling
    'g k' = move previous sibling
    'g h' = move parent
    'g l' = move first reply
    ' ' = move next

[accounts]
    [[aaron@address1.com]
        realname = Aaron Young
        address = aaron@address1.com
        sendmail_command = msmtp --account=ajy -t

                [[[abook]]]
            type = shellcommand
            command = khard email -s
            regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)'
            ignorecase = True

    [[aaron@address2.com]]
        realname = Aaron Young
        address = aaron@address2.com
        sendmail_command = msmtp --account=gmail -t

                [[[abook]]]
            type = shellcommand
            command = khard email -s
            regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)'
            ignorecase = True

    [[aaron@address3.com]]
        realname = Aaron Young
        address = aaron@address3.com
        sendmail_command = msmtp --account=work -t

                [[[abook]]]
            type = shellcommand
            command = khard email -s
            regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)'
            ignorecase = True

OK – a couple notes.

  1. I start with a few basic settings. I tell alot to open a new terminal window, running vim, when composing an email.
  2. Next, I define the keybindings – first, global keybindings, then the keybindings in different views (thread, envelope, etc.). Note that some of these keybindings can run a series of commands, one after the next.
  3. Finally, I define basic settings for each email account – the sendmail command, and the address book configuration. When I am composing email, I can use my tab key to find email addresses from the khard address book.

HTML email

You’ll likely want to be able to read HTML email. The easiest way to handle this is to install w3m, a basic console web browser:

  • sudo pacman -S w3m
  • Then, vim ~/.mailcap

Contents of your ~/.mailcap file:

text/html; w3m -dump -o -document_charset=%{charset} %s; nametemplate=%s.html; copiousoutput

That’ll do it.

Syncing your configuration files

I’ve mentioned that I use Syncthing for syncing my email folder. I also sync my alot and khard configs from one workstation to another. This way I don’t need to worry about having an out-of-date configuration file on one of my machines.

Configuring khard

I’m not going to get too far in here since it’s right at the edge of the scope of this series. Here are the basics:

  • If you are using a CardDav server to handle your contacts, you should set up vdirsyncer to periodically sync your contacts into a directory (the contacts directory is called a vdir). You can sync this directory between your computers.
  • Of course, after installing khard, you’ll want to set up your config file. Run vim ~/.config/khard/khard.conf. Here’s the example config. Modify as needed.
  • Using the above alot configuration settings, alot will use the khard address book to tab-complete email addresses for you when composing email.

Using alot

When you open alot, you’ll be greeted with any unread / inbox messages you have. Note that you’re not viewing an IMAP directory – instead, it’s a view of messages with a certain tag.

You can press o, or type :search to start searching:

  • :search tag:archive
  • :search Chris
  • etc.

To compose, type :compose and fill out the information you’re prompted for. You’ll get a Vim window where you can write the email. When you’re done, type :wq in vim to save and quit. Then, back at your alot window, type :send to send the email (but you’ll need msmtp installed and configured to actually send the mail).

These are a couple basic usage tips. You’ll pick up alot pretty quickly. It’s handy to remember that typing a question mark ? will show you a list of keybindings for your current view, and you can use the :help command to give you additional hints about a particular command.

Next

Next, we need to get msmtp installed, so you can send email. Stay tuned!

Leave a Reply

Your email address will not be published. Required fields are marked *