Files
obsidian/tank/programming/Mailserver setup/color scheming.md
T
2026-05-07 14:39:10 +02:00

8.6 KiB
Executable File

Great! Let's take your aerc setup to the next level. Here are several enhancements:

1. Color Schemes & Styling

Custom styleset for priority/tags

Create a custom styleset:

mkdir -p ~/.config/aerc/stylesets
nano ~/.config/aerc/stylesets/custom

Paste this (customize colors as you like):

# Basic UI
*.default=true
*.normal=default
*.selected=reverse
border.default=true

# Message list - Priority coloring
msglist_unread.fg=bold
msglist_unread.bg=default

# Priority 1 - RED/URGENT
msglist_marked.fg=red
msglist_marked.bg=default
msglist_marked.selected.fg=black
msglist_marked.selected.bg=red

# Tag-based coloring
msglist_flagged.fg=yellow
msglist_flagged.bg=default

# Read messages - dimmed
msglist_read.fg=242
msglist_read.bg=default

# Deleted
msglist_deleted.fg=darkgray
msglist_deleted.bg=default

# Message viewer
title.fg=cyan
title.bg=default
header.fg=green
header.bg=default

# Composer
tab.fg=white
tab.bg=black
tab.selected.fg=black
tab.selected.bg=cyan

# Status bar
statusline_default.fg=white
statusline_default.bg=black
statusline_error.fg=red
statusline_error.bg=black
statusline_success.fg=green
statusline_success.bg=black

# Sidebar folders
dirlist_default.fg=white
dirlist_default.bg=default
dirlist_unread.fg=cyan
dirlist_unread.bg=default
dirlist_recent.fg=yellow
dirlist_recent.bg=default

# Completion menu
completion_default.fg=white
completion_default.bg=black
completion_selected.fg=black
completion_selected.bg=cyan

# Spinner
spinner.fg=cyan
spinner.bg=default

Enable it in ~/.config/aerc/aerc.conf:

[ui]
styleset-name=custom

Advanced: Color by tag/priority

In ~/.config/aerc/aerc.conf:

[ui]
# Show icons/symbols for tags
icon-unread=
icon-replied=
icon-attachment=📎
icon-signed=🔒
icon-encrypted=🔐

# Threading
threading-enabled=true

Message list formatting with colors

Edit ~/.config/aerc/aerc.conf:

[ui]
# Custom index format with conditional colors
index-columns = date<20,name<25,flags>4,subject<*
column-date = {{.DateAutoFormat .Date.Local}}
column-name = {{index (.From | names) 0}}
column-flags = {{.Flags | join ""}}
column-subject = {{.ThreadPrefix}}{{.Subject}}

# Timestap format
timestamp-format=2006-01-02 15:04
this-day-time-format=15:04
this-week-time-format=Mon 15:04
this-year-time-format=Jan 02

2. Advanced Tag-Based Coloring

Create a script to colorize by tag:

nano ~/.config/aerc/scripts/colorize-tags.sh
#!/bin/bash
# Color messages based on notmuch tags

MSGID="$1"
TAGS=$(notmuch search --output=tags id:$MSGID)

if echo "$TAGS" | grep -q "priority1"; then
    echo -e "\033[1;31m"  # Bold red
elif echo "$TAGS" | grep -q "priority2"; then
    echo -e "\033[1;33m"  # Bold yellow
elif echo "$TAGS" | grep -q "spam"; then
    echo -e "\033[0;90m"  # Gray
elif echo "$TAGS" | grep -q "newsletter"; then
    echo -e "\033[0;36m"  # Cyan
else
    echo -e "\033[0m"     # Default
fi

Make executable:

chmod +x ~/.config/aerc/scripts/colorize-tags.sh

3. Better Message Viewing

Syntax highlighting for code in emails

Install:

sudo pacman -S highlight bat

Edit ~/.config/aerc/aerc.conf:

[viewer]
pager=less -R

# Syntax highlight code blocks
text/plain=bat --style=plain --paging=never --color=always

# Or use highlight
# text/plain=highlight -O ansi --force

Better HTML rendering with custom CSS

Create ~/.config/aerc/html.css:

body {
    font-family: sans-serif;
    max-width: 800px;
    margin: 20px auto;
    line-height: 1.6;
    color: #e0e0e0;
    background: #1a1a1a;
}

a {
    color: #58a6ff;
}

code {
    background: #2d2d2d;
    padding: 2px 6px;
    border-radius: 3px;
}

pre {
    background: #2d2d2d;
    padding: 10px;
    overflow-x: auto;
}

Update viewer:

[viewer]
html-filter=pandoc -f html -t plain | bat --style=plain --color=always

Install fzf integration

sudo pacman -S fzf

Add to ~/.config/aerc/binds.conf:

[messages]
# Fuzzy find emails
/ = :term fzf-aerc<Enter>

Create the script ~/.local/bin/fzf-aerc:

#!/bin/bash
notmuch search --output=messages '*' | \
    fzf --preview 'notmuch show {}' | \
    xargs -I {} aerc ":open {}<Enter>"

Make executable:

chmod +x ~/.local/bin/fzf-aerc

5. Email Templates

Create templates directory:

mkdir -p ~/.config/aerc/templates

Quick reply template

~/.config/aerc/templates/quick-reply:

Thanks for reaching out!

{{.OriginalMessage}}

Best regards,
{{.From}}

Meeting confirmation template

~/.config/aerc/templates/meeting-confirm:

Hi {{.To}},

Confirmed! Looking forward to our meeting on {{.Subject}}.

Best,
{{.From}}

Use templates with keybinding

In ~/.config/aerc/binds.conf:

[messages]
,tr = :reply -t quick-reply<Enter>
,tm = :reply -t meeting-confirm<Enter>

6. Contact Management Integration

Better abook integration

sudo pacman -S abook

Import contacts:

# From notmuch
notmuch address --output=sender '*' | sort -u > /tmp/contacts.txt

# Import to abook (manual process, or script it)

Add to ~/.config/aerc/aerc.conf:

[compose]
address-book-cmd=abook --mutt-query '%s'

Or use khard (CardDAV)

yay -S khard

Sync with ProtonMail contacts via vdirsyncer.

7. Notification System

Desktop notifications for new mail

Install:

sudo pacman -S libnotify

Update ~/.local/bin/sync-mail.sh:

#!/bin/bash

# Store count before sync
BEFORE=$(notmuch count tag:unread)

# Sync
mbsync -a
notmuch new
PYTHONWARNINGS="ignore::UserWarning" afew --tag --new

# Count after
AFTER=$(notmuch count tag:unread)
NEW=$((AFTER - BEFORE))

# Notify if new mail
if [ $NEW -gt 0 ]; then
    # Check for priority mail
    PRIORITY=$(notmuch count tag:priority1 AND tag:unread)
    
    if [ $PRIORITY -gt 0 ]; then
        notify-send -u critical "📧 Urgent Mail" "$PRIORITY high priority message(s)"
    else
        notify-send "📬 New Mail" "$NEW new message(s)"
    fi
fi

echo "Mail sync complete at $(date)"

Sound notifications

sudo pacman -S sox

Add to sync script:

if [ $PRIORITY -gt 0 ]; then
    play -n synth 0.3 sine 800 vol 0.5
fi

8. Productivity Integrations

Send emails to task manager

Create ~/.config/aerc/scripts/email-to-task.sh:

#!/bin/bash
# Pipe email to task manager

SUBJECT=$(notmuch show --format=json "$1" | jq -r '.[0][0][0].headers.Subject')
FROM=$(notmuch show --format=json "$1" | jq -r '.[0][0][0].headers.From')

# Add to taskwarrior
task add "Email: $SUBJECT from $FROM" +email

Keybinding:

[messages]
,tt = :pipe ~/.config/aerc/scripts/email-to-task.sh<Enter>

Calendar integration

sudo pacman -S khal vdirsyncer

Parse calendar invites automatically in viewer.

9. Advanced Filtering Scripts

Auto-respond to certain senders

Create ~/.config/notmuch/default/hooks/post-new:

#!/bin/bash

# Auto-archive newsletters
notmuch tag +archived -inbox -- tag:newsletter AND tag:new

# Auto-mark as read if from automated systems
notmuch tag -unread -- tag:automated AND tag:new

# Flag urgent keywords
notmuch tag +urgent -- subject:"URGENT" AND tag:new

Make executable:

chmod +x ~/.config/notmuch/default/hooks/post-new

10. Performance Optimizations

In ~/.config/aerc/aerc.conf:

[ui]
# Cache headers for speed
cache-headers=true

# Faster threading
threading-enabled=true

# Limit initial load
dirlist-delay=200ms

# Async loading
sort=reverse-date

[viewer]
# Faster paging
parse-http-links=false
max-mime-height=0

11. Vim-like Navigation Improvements

Enhanced ~/.config/aerc/binds.conf:

[messages]
# Vim-style marks
m = :mark -t<Enter>
M = :mark -T<Enter>
' = :mark -v<Enter>

# Quick archive/delete
<Space>d = :move Trash<Enter>
<Space>a = :move Archive<Enter>

# Macro-like sequences
,aa = :mark -a<Enter>:archive<Enter>
,dd = :mark -a<Enter>:delete<Enter>

# Quick jumps
gg = :select 0<Enter>
G = :select -1<Enter>
<C-u> = :prev 10<Enter>
<C-d> = :next 10<Enter>

# Split view
<C-w>v = :vsplit<Enter>
<C-w>s = :split<Enter>
<C-w>c = :close<Enter>

12. Status Bar Customization

In ~/.config/aerc/aerc.conf:

[statusline]
status-columns = left<*,center>=,right>*
column-left = {{.Account}}:{{.Folder}} [{{.StatusInfo}}]
column-center = {{.StatusDisplay}}
column-right = {{.TrayInfo}} {{.PendingKeys}}

Quick Install Script for All Enhancements

Want me to create a single script that installs and configures all of these at once? Or would you rather add them one by one as you explore?

Which enhancements interest you most? I can dive deeper into any of these!