user/aerc: restructure
This commit is contained in:
parent
1354d932f8
commit
4e6fff448d
3 changed files with 171 additions and 310 deletions
169
home/modules/mail/aerc.nix
Normal file
169
home/modules/mail/aerc.nix
Normal file
|
@ -0,0 +1,169 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
exec = cmd: ":${cmd}<Enter>";
|
||||
fill = cmd: ":${cmd}<space>";
|
||||
|
||||
globalBinds = {
|
||||
"gt" = exec "next-tab";
|
||||
"gT" = exec "prev-tab";
|
||||
};
|
||||
|
||||
commonMessageBinds = {
|
||||
"U" = exec "unsubscribe";
|
||||
"D" = exec "delete";
|
||||
"A" = exec "archive flat";
|
||||
"mS" = exec "move Junk";
|
||||
};
|
||||
in
|
||||
{
|
||||
accounts.email.maildirBasePath = "${config.xdg.dataHome}/mail";
|
||||
|
||||
# See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix
|
||||
programs.aerc = {
|
||||
enable = true;
|
||||
# See: https://man.archlinux.org/man/aerc-config.5.en
|
||||
extraConfig = {
|
||||
general = {
|
||||
unsafe-accounts-conf = true;
|
||||
};
|
||||
|
||||
ui = {
|
||||
index-format = "%-17.17D %-20.20n %Z %-20.20g %s";
|
||||
# See https://godoc.org/time#Time.Format
|
||||
timestamp-format = "2006-01-02 15:04 MST";
|
||||
this-day-time-format = "15:04";
|
||||
this-week-time-format = "Monday 15:04";
|
||||
this-year-time-format = "02 January";
|
||||
pinned-tab-marker = "車";
|
||||
border-char-vertical = "│";
|
||||
border-char-horizontal = "─";
|
||||
fuzzy-complete = true;
|
||||
new-message-bell = true;
|
||||
};
|
||||
|
||||
statusline = {
|
||||
display-mode = "icon";
|
||||
};
|
||||
|
||||
# https://git.sr.ht/~rjarry/aerc/tree/master/item/doc/aerc-config.5.scd
|
||||
filters = {
|
||||
".headers" = "colorize";
|
||||
"text/html" = "html | colorize";
|
||||
"text/plain" = "colorize";
|
||||
"text/rfc822-headers" = "colorize";
|
||||
# "text/*" = "${pkgs.bat}/bin/bat -fpp --file-name='$AERC_FILENAME'";
|
||||
"message/delivery-status" = "cat | colorize";
|
||||
};
|
||||
};
|
||||
extraBinds = {
|
||||
messages = lib.mkMerge [
|
||||
globalBinds
|
||||
commonMessageBinds
|
||||
{
|
||||
"q" = exec "quit";
|
||||
|
||||
"j" = exec "next";
|
||||
"<Down>" = exec "next";
|
||||
"<C-d>" = exec "next 50%";
|
||||
|
||||
"k" = exec "prev";
|
||||
"<Up>" = exec "prev";
|
||||
"<C-b>" = exec "prev 50%";
|
||||
|
||||
"gg" = exec "select 0";
|
||||
"G" = exec "select -1";
|
||||
|
||||
"J" = exec "next-folder";
|
||||
"K" = exec "prev-folder";
|
||||
"c" = fill "cf";
|
||||
|
||||
"<Enter>" = exec "view";
|
||||
"C" = exec "compose";
|
||||
|
||||
"/" = fill "search";
|
||||
"\\" = fill "filter";
|
||||
"n" = exec "next-result";
|
||||
"N" = exec "prev-result";
|
||||
#"D" = exec "modify-labels +deleted -inbox";
|
||||
#"A" = exec "modify-labels -inbox";
|
||||
#"ms" = exec "modify-labels +spam -inbox";
|
||||
#"mS" = exec "modify-labels -spam +inbox";
|
||||
}
|
||||
];
|
||||
|
||||
view = lib.mkMerge [
|
||||
globalBinds
|
||||
commonMessageBinds
|
||||
{
|
||||
"q" = exec "close";
|
||||
"O" = exec "open";
|
||||
"S" = fill "save";
|
||||
|
||||
"f" = exec "forward";
|
||||
|
||||
"rr" = exec "reply -a";
|
||||
"rq" = exec "reply -aq";
|
||||
"Rr" = exec "reply";
|
||||
"Rq" = exec "reply -q";
|
||||
|
||||
"<C-k>" = exec "prev-part";
|
||||
"<C-j>" = exec "next-part";
|
||||
"J" = exec "next";
|
||||
"K" = exec "prev";
|
||||
}
|
||||
];
|
||||
|
||||
compose = lib.mkMerge [
|
||||
globalBinds
|
||||
{
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = exec "prev-field";
|
||||
"<C-j>" = exec "next-field";
|
||||
"<tab>" = exec "next-field";
|
||||
}
|
||||
];
|
||||
|
||||
"compose::editor" = {
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = exec "prev-field";
|
||||
"<C-j>" = exec "next-field";
|
||||
};
|
||||
|
||||
"compose::review" = {
|
||||
"y" = exec "send";
|
||||
"n" = exec "abort";
|
||||
"p" = exec "postpone";
|
||||
"q" = exec "choose -o d discard abort -o p postpone postpone";
|
||||
"e" = exec "edit";
|
||||
"a" = fill "attach";
|
||||
"d" = fill "detach";
|
||||
};
|
||||
};
|
||||
|
||||
stylesets.default = {
|
||||
"*.selected.reverse" = true;
|
||||
"title.reverse" = true;
|
||||
"header.bold" = true;
|
||||
"*error.bold" = true;
|
||||
"error.fg" = 1;
|
||||
"warning.fg" = 3;
|
||||
"success.fg" = 2;
|
||||
"msglist_unread.bold" = true;
|
||||
"msglist_deleted.fg" = 10;
|
||||
"tab.fg" = 0;
|
||||
"tab.selected.reverse" = false;
|
||||
"tab.selected.bold" = true;
|
||||
"tab.selected.bg" = 2;
|
||||
"dirlist_default.bg" = 18;
|
||||
"border.fg" = 0;
|
||||
"statusline_default.bg" = 18;
|
||||
"statusline_error.fg" = 1;
|
||||
"statusline_error.reverse" = true;
|
||||
"statusline_success.fg" = 2;
|
||||
"statusline_success.reverse" = true;
|
||||
"completion_default.bg" = 0;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
#!/usr/bin/env -S awk -f
|
||||
# Copyright (c) 2022 Robin Jarry
|
||||
# Modified 2022-06-16 by Simon Bruder to use ANSI colors
|
||||
# Modified 2022-06-16 by Simon Bruder to a /usr/bin/env shebang
|
||||
|
||||
BEGIN {
|
||||
url = "\x1b[33m" # yellow
|
||||
header = "\x1b[35m" # purple
|
||||
signature = "\x1b[35m" # purple
|
||||
diff_meta = "\x1b[1;37m" # bold white
|
||||
diff_chunk = "\x1b[36m" # cyan
|
||||
diff_add = "\x1b[32m" # green
|
||||
diff_del = "\x1b[31m" # red
|
||||
quote_1 = "\x1b[34m" # blue
|
||||
quote_2 = "\x1b[91m" # orange
|
||||
quote_3 = "\x1b[35m" # purple
|
||||
quote_4 = "\x1b[95m" # pink
|
||||
quote_x = "\x1b[37m" # gray
|
||||
reset = "\x1b[0m"
|
||||
# state
|
||||
in_diff = 0
|
||||
in_signature = 0
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
# patterns
|
||||
header_pattern = @/^[A-Z][[:alnum:]-]+:/
|
||||
url_pattern = @/[a-z]{2,6}:\/\/[[:graph:]]+|(mailto:)?[[:alnum:]_\+\.~\/-]*[[:alnum:]_]@[[:lower:]][[:alnum:]\.-]*[[:lower:]]/
|
||||
}
|
||||
function color_quote(line) {
|
||||
level = 0
|
||||
quotes = ""
|
||||
while (line ~ /^>/) {
|
||||
level += 1
|
||||
quotes = quotes ">"
|
||||
line = substr(line, 2)
|
||||
while (line ~ /^ /) {
|
||||
quotes = quotes " "
|
||||
line = substr(line, 2)
|
||||
}
|
||||
}
|
||||
if (level == 1) {
|
||||
color = quote_1
|
||||
} else if (level == 2) {
|
||||
color = quote_2
|
||||
} else if (level == 3) {
|
||||
color = quote_3
|
||||
} else if (level == 4) {
|
||||
color = quote_4
|
||||
} else {
|
||||
color = quote_x
|
||||
}
|
||||
if (line ~ /^\+/) {
|
||||
return color quotes diff_add line reset
|
||||
} else if (line ~ /^-/) {
|
||||
return color quotes diff_del line reset
|
||||
}
|
||||
gsub(url_pattern, url "&" color, line)
|
||||
return color quotes line reset
|
||||
}
|
||||
{
|
||||
# Strip carriage returns from line
|
||||
sub(/\r$/, "")
|
||||
|
||||
if (in_diff) {
|
||||
if ($0 ~ /^-- ?$/) {
|
||||
in_signature = 1
|
||||
in_diff = 0
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
$0 = signature $0 reset
|
||||
} else if ($0 ~ /^@@ /) {
|
||||
$0 = diff_chunk $0 reset
|
||||
} else if ($0 ~ /^(diff --git|index|---|\+\+\+) /) {
|
||||
$0 = diff_meta $0 reset
|
||||
} else if ($0 ~ /^\+/) {
|
||||
$0 = diff_add $0 reset
|
||||
} else if ($0 ~ /^-/) {
|
||||
$0 = diff_del $0 reset
|
||||
}
|
||||
} else if (in_signature) {
|
||||
gsub(url_pattern, url "&" signature)
|
||||
$0 = signature $0 reset
|
||||
} else if (in_headers) {
|
||||
if ($0 ~ /^$/) {
|
||||
in_signature = 0
|
||||
in_diff = 0
|
||||
in_headers = 0
|
||||
in_body = 1
|
||||
} else {
|
||||
sub(header_pattern, header "&" reset)
|
||||
gsub(url_pattern, url "&" reset)
|
||||
}
|
||||
} else if (in_body) {
|
||||
if ($0 ~ /^>/) {
|
||||
$0 = color_quote($0)
|
||||
} else if ($0 ~ /^diff --git /) {
|
||||
in_signature = 0
|
||||
in_diff = 1
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
$0 = diff_meta $0 reset
|
||||
} else if ($0 ~ /^-- ?$/) {
|
||||
in_signature = 1
|
||||
in_diff = 0
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
$0 = signature $0 reset
|
||||
} else {
|
||||
gsub(url_pattern, url "&" reset)
|
||||
}
|
||||
} else if ($0 ~ /^diff --git /) {
|
||||
in_signature = 0
|
||||
in_diff = 1
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
$0 = diff_meta $0 reset
|
||||
} else if ($0 ~ /^-- ?$/) {
|
||||
in_signature = 1
|
||||
in_diff = 0
|
||||
in_headers = 0
|
||||
in_body = 0
|
||||
$0 = signature $0 reset
|
||||
} else if ($0 ~ header_pattern) {
|
||||
in_signature = 0
|
||||
in_diff = 0
|
||||
in_headers = 1
|
||||
in_body = 0
|
||||
sub(header_pattern, header "&" reset)
|
||||
gsub(url_pattern, url "&" reset)
|
||||
} else {
|
||||
in_signature = 0
|
||||
in_diff = 0
|
||||
in_headers = 0
|
||||
in_body = 1
|
||||
if ($0 ~ /^>/) {
|
||||
$0 = color_quote($0)
|
||||
} else {
|
||||
gsub(url_pattern, url "&" reset)
|
||||
}
|
||||
}
|
||||
|
||||
print
|
||||
}
|
||||
|
|
@ -1,169 +1,5 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ ... }:
|
||||
|
||||
let
|
||||
exec = cmd: ":${cmd}<Enter>";
|
||||
fill = cmd: ":${cmd}<space>";
|
||||
|
||||
globalBinds = {
|
||||
"gt" = exec "next-tab";
|
||||
"gT" = exec "prev-tab";
|
||||
};
|
||||
|
||||
commonMessageBinds = {
|
||||
"U" = exec "unsubscribe";
|
||||
"D" = exec "delete";
|
||||
"A" = exec "archive flat";
|
||||
"mS" = exec "move Junk";
|
||||
};
|
||||
in
|
||||
{
|
||||
accounts.email.maildirBasePath = "${config.xdg.dataHome}/mail";
|
||||
|
||||
# See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix
|
||||
programs.aerc = {
|
||||
enable = true;
|
||||
# See: https://man.archlinux.org/man/aerc-config.5.en
|
||||
extraConfig = {
|
||||
general = {
|
||||
unsafe-accounts-conf = true;
|
||||
};
|
||||
|
||||
ui = {
|
||||
index-format = "%-17.17D %-20.20n %Z %-20.20g %s";
|
||||
# See https://godoc.org/time#Time.Format
|
||||
timestamp-format = "2006-01-02 15:04 MST";
|
||||
this-day-time-format = "15:04";
|
||||
this-week-time-format = "Monday 15:04";
|
||||
this-year-time-format = "02 January";
|
||||
pinned-tab-marker = "車";
|
||||
border-char-vertical = "│";
|
||||
border-char-horizontal = "─";
|
||||
fuzzy-complete = true;
|
||||
new-message-bell = true;
|
||||
};
|
||||
|
||||
statusline = {
|
||||
display-mode = "icon";
|
||||
};
|
||||
|
||||
# https://git.sr.ht/~rjarry/aerc/tree/master/item/doc/aerc-config.5.scd
|
||||
filters = {
|
||||
".headers" = "colorize";
|
||||
"text/html" = "html | colorize";
|
||||
"text/plain" = "colorize";
|
||||
"text/rfc822-headers" = "colorize";
|
||||
# "text/*" = "${pkgs.bat}/bin/bat -fpp --file-name='$AERC_FILENAME'";
|
||||
"message/delivery-status" = "cat | colorize";
|
||||
};
|
||||
};
|
||||
extraBinds = {
|
||||
messages = lib.mkMerge [
|
||||
globalBinds
|
||||
commonMessageBinds
|
||||
{
|
||||
"q" = exec "quit";
|
||||
|
||||
"j" = exec "next";
|
||||
"<Down>" = exec "next";
|
||||
"<C-d>" = exec "next 50%";
|
||||
|
||||
"k" = exec "prev";
|
||||
"<Up>" = exec "prev";
|
||||
"<C-b>" = exec "prev 50%";
|
||||
|
||||
"gg" = exec "select 0";
|
||||
"G" = exec "select -1";
|
||||
|
||||
"J" = exec "next-folder";
|
||||
"K" = exec "prev-folder";
|
||||
"c" = fill "cf";
|
||||
|
||||
"<Enter>" = exec "view";
|
||||
"C" = exec "compose";
|
||||
|
||||
"/" = fill "search";
|
||||
"\\" = fill "filter";
|
||||
"n" = exec "next-result";
|
||||
"N" = exec "prev-result";
|
||||
#"D" = exec "modify-labels +deleted -inbox";
|
||||
#"A" = exec "modify-labels -inbox";
|
||||
#"ms" = exec "modify-labels +spam -inbox";
|
||||
#"mS" = exec "modify-labels -spam +inbox";
|
||||
}
|
||||
];
|
||||
|
||||
view = lib.mkMerge [
|
||||
globalBinds
|
||||
commonMessageBinds
|
||||
{
|
||||
"q" = exec "close";
|
||||
"O" = exec "open";
|
||||
"S" = fill "save";
|
||||
|
||||
"f" = exec "forward";
|
||||
|
||||
"rr" = exec "reply -a";
|
||||
"rq" = exec "reply -aq";
|
||||
"Rr" = exec "reply";
|
||||
"Rq" = exec "reply -q";
|
||||
|
||||
"<C-k>" = exec "prev-part";
|
||||
"<C-j>" = exec "next-part";
|
||||
"J" = exec "next";
|
||||
"K" = exec "prev";
|
||||
}
|
||||
];
|
||||
|
||||
compose = lib.mkMerge [
|
||||
globalBinds
|
||||
{
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = exec "prev-field";
|
||||
"<C-j>" = exec "next-field";
|
||||
"<tab>" = exec "next-field";
|
||||
}
|
||||
];
|
||||
|
||||
"compose::editor" = {
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = exec "prev-field";
|
||||
"<C-j>" = exec "next-field";
|
||||
};
|
||||
|
||||
"compose::review" = {
|
||||
"y" = exec "send";
|
||||
"n" = exec "abort";
|
||||
"p" = exec "postpone";
|
||||
"q" = exec "choose -o d discard abort -o p postpone postpone";
|
||||
"e" = exec "edit";
|
||||
"a" = fill "attach";
|
||||
"d" = fill "detach";
|
||||
};
|
||||
};
|
||||
|
||||
stylesets.default = {
|
||||
"*.selected.reverse" = true;
|
||||
"title.reverse" = true;
|
||||
"header.bold" = true;
|
||||
"*error.bold" = true;
|
||||
"error.fg" = 1;
|
||||
"warning.fg" = 3;
|
||||
"success.fg" = 2;
|
||||
"msglist_unread.bold" = true;
|
||||
"msglist_deleted.fg" = 10;
|
||||
"tab.fg" = 0;
|
||||
"tab.selected.reverse" = false;
|
||||
"tab.selected.bold" = true;
|
||||
"tab.selected.bg" = 2;
|
||||
"dirlist_default.bg" = 18;
|
||||
"border.fg" = 0;
|
||||
"statusline_default.bg" = 18;
|
||||
"statusline_error.fg" = 1;
|
||||
"statusline_error.reverse" = true;
|
||||
"statusline_success.fg" = 2;
|
||||
"statusline_success.reverse" = true;
|
||||
"completion_default.bg" = 0;
|
||||
};
|
||||
};
|
||||
imports = [ ./aerc.nix ];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue