Published on : 2026-06-03 10:10
I mentioned aerc in my post "Living in the terminal" [1] and have
just realized that I didn't write a post on installing and
configuring aerc. This setup provides a fast, keyboard-driven mail
experience with contacts accessible from the command line.
Screenshots of my aerc setup
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
(IMG) Aerc - View email
(IMG) Aerc - renamed Gmail folders
(IMG) Aerc - PGP signed email
(IMG) Aerc - Dunst notification
(IMG) Aerc - addressbook autocomplete
In this tutorial I will use my Gmail account. You can use
essentially any email provider that supports standard IMAP and
SMTP access.
What's needed
‾‾‾‾‾‾‾‾‾‾‾‾‾
* aerc - terminal email client
* Gmail account or any other IMAP and SMTP provider
* pass - Unix password manager backed by GPG
* khard - command-line contacts manager using vCard files
* gnupg - stores secrets encrypted with GPG keys.
Install what's needed
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
sudo pacman -S aerc pass khard gnupg
Initialize pass
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Generate a GPG key if you do not already have one:
gpg --full-generate-key
pass init "email@address"
pass needs an existing GPG key. Use the same email address for
both gpg and pass.
Gmail App Password
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
First, create an App Password:
* open your Google account settings.
* go to Security
* enable 2-Step Verification if it's not enabled
* go to App passwords and generate a new App Password for Mail.
Store the App generated password using pass
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
pass insert mail/gmail
You can verify the App password with:
pass show mail/gmail
Setup aerc
‾‾‾‾‾‾‾‾‾‾
You don't need to create all configuration files manually.
On first launch, aerc can guide you through creating an account
configuration using its setup wizard. Run aerc with:
aerc
The wizard will ask for details such as:
* email address
* IMAP server
* SMTP server
* username
* password
Once the initial configuration is working, you can edit the
generated files to integrate pass, customize folders, add
signatures, and configure address completion with khard.
accounts.conf
‾‾‾‾‾‾‾‾‾‾‾‾‾
Edit ~/.config/aerc/accounts.conf and add the following:
[Account name]
source = imaps://youremail%40gmail.com@imap.gmail.com:993
source-cred-cmd = pass mail/gmail
outgoing = smtp://youremail%40gmail.com@smtp.gmail.com:587
outgoing-cred-cmd = pass mail/gmail
default = INBOX
from = YourName <youremail@gmail.com>
cache-headers = true
check-mail = 15m
postpone = Drafts
folder-map = ~/.config/aerc/folders
folders-sort = Inbox,Starred,Drafts,All Mail,Sent,Spam,Trash
copy-to-sent = true
signature-file = ~/.config/aerc/signature
Rename folders
‾‾‾‾‾‾‾‾‾‾‾‾‾‾
You can customize the sidebar in aerc with custom folder names and
ditch the ugly [Gmail] ones. Edit ~/.config/aerc/folders
(folder-map param in aerc.conf):
Inbox = INBOX
Starred = [Gmail]/Starred
Drafts = [Gmail]/Drafts
Sent = [Gmail]/Sent Mail
Spam = [Gmail]/Spam
Trash = [Gmail]/Bin
All Mail = [Gmail]/All Mail
Sort folders
‾‾‾‾‾‾‾‾‾‾‾‾
You can also sort and order the folders as you please. You can see
how I sorted mine in the account.conf above (folder-sort).
Misc settings
‾‾‾‾‾‾‾‾‾‾‾‾‾
In the accounts.conf above I setup a signature file, chose that
unfinished emails (postponed) will be moved to the Drafts folder
and that sent emails are copied to the Sent folder.
(copy-to-sent = true)
Address book
‾‾‾‾‾‾‾‾‾‾‾‾
Edit ~/.config/khard/khard.conf and add this config:
[addressbooks]
[[main]]
path = ~/.config/khard/contacts/
[general]
debug = no
default_action = list
show_nicknames = no
[contact table]
display = first_name
group_by_addressbook = no
reverse_horizontal_cut = no
show_uids = no
Your contacts/vcard files will be saved in the
.config/khard/contacts/ directory. You know why ? So you can
backup everything when you backup your dot files and then
restow [2] them.
Now, let's instruct aerc to use and manage khard contacts.
Edit ~/.config/aerc/aerc.conf and add the code below in the
[compose] block:
address-book-cmd=khard email --remove-first-line --parsable %s
Now, whenever you compose an email and type addresses in the TO
field your contacts will appear.
Adding contacts to khard from aerc
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
If you receive an email from an address not in your address book
you can easily use a bind. Edit ~/.config/aerc/binds.conf.
In the [view] block add:
aa = :pipe -m khard add-email<Enter>
Now, whenever you are viewing an email pressing aa will prompt
you to add the senders email address to your hkard address book.
New Email Notification
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Edit ~/.config/aerc/aerc.conf. In the [hooks] block add:
mail-received=dunstify -t 60000 "[$AERC_ACCOUNT] Mail from \
$AERC_FROM_NAME" "$AERC_SUBJECT"
I am using dunst. My notification stays on the screen for
1 minute or until I click on it.
Using aerc
‾‾‾‾‾‾‾‾‾‾
The most used keybinds in my opinion are:
* CTRL + UP/DOWN - move between folders
* UP / DOWN - move between emails
* ENTER - opens an email
* C - opens compose window
* Rr - reply
* SPACE - selects the highlighted email
* D - deletes selected email/s
* q - closes open message
* S - vertical split
* s - horizontal split
All keybinds are easily accessible by pressing SHIFT + /
(yes, the question mark ?).
Optional: PGP-Signed Email
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Since this setup already uses GPG for pass, you're only a small
step away from signing outgoing email. While relatively few people
verify OpenPGP signatures these days, signed messages provide
cryptographic proof that an email was sent by you and has not
been modified in transit. Think of it as a digital wax seal for
your email: visible to everyone, but difficult to forge.
You can sign an email by pressing s in the "Send this email ?"
confirmation box.
aerc, gpg, pass, and khard have made email fast, efficient, and
entirely keyboard-driven. The only downside is that my mouse now
has so much free time that it's considering early retirement.
(DIR) [1] Living in the terminal
(DIR) [2] Managing Dotfiles with GNU Stow
Good bye 🐭! Hello ⌨️!
(DIR) Back to my phlog