summaryrefslogtreecommitdiff
path: root/profiles/email/neomutt.nix
blob: 7940fc60b2e2b156c919eff931c51e68260c94a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{
  ...
}: {
  hm = {
    programs.msmtp = {
      enable = true;
    };

    xdg.configFile."neomutt/mailcap" = {
      text = ''
        text/plain; $EDITOR %s ;
        text/html; openfile %s ; nametemplate=%s.html
        text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump -width=1024 %s; nametemplate=%s.html; copiousoutput;
        image/*; openfile %s ;
        video/*; setsid mpv --quiet %s &; copiousoutput
        audio/*; mpv %s ;
        application/pdf; openfile %s ;
        application/pgp-encrypted; gpg -d '%s'; copiousoutput;
        application/pgp-keys; gpg --import '%s'; copiousoutput;
        application/x-subrip; $EDITOR %s ;
      '';
    };

    programs.neomutt = {
      enable = true;
      sort = "reverse-date";
      sidebar = {
        enable = true;
      };
      extraConfig = ''
        set use_threads=yes
        set send_charset="us-ascii:utf-8"
        set mailcap_path = $HOME/.config/neomutt/mailcap
        set mime_type_query_command = "file --mime-type -b %s"
        set date_format="%y/%m/%d %I:%M%p"
        set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)"
        set smtp_authenticators = 'gssapi:login'
        set query_command = "echo %s | xargs khard email --parsable --"
        set rfc2047_parameters = yes
        set sleep_time = 0		# Pause 0 seconds for informational messages
        set markers = no		# Disables the `+` displayed at line wraps
        set mark_old = no		# Unread mail stay unread until read
        set mime_forward = no	# mail body is forwarded as text
        set forward_attachments = yes	# attachments are forwarded with mail
        set wait_key = no		# mutt won't ask "press key to continue"
        set fast_reply			# skip to compose when replying
        set fcc_attach			# save attachments with the body
        set forward_format = "Fwd: %s"	# format of subject when forwarding
        set forward_quote		# include message in forwards
        set reverse_name		# reply as whomever it was to
        set include			# include message in replies
        set mail_check=0 # to avoid lags using IMAP with some email providers (yahoo for example)
        auto_view text/html		# automatically show html (mailcap uses lynx)
        auto_view application/pgp-encrypted
        #set display_filter = "tac | sed '/\\\[-- Autoview/,+1d' | tac" # Suppress autoview messages.
        alternative_order text/plain text/enriched text/html

        set sidebar_visible = yes
        set sidebar_width = 20
        set sidebar_short_path = yes
        set sidebar_next_new_wrap = yes
        set mail_check_stats
        set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?'
        bind index,pager \Co sidebar-open
        bind index,pager \Cp sidebar-prev-new
        bind index,pager \Cn sidebar-next-new
        bind index,pager B sidebar-toggle-visible

        # Default index colors:
        color index yellow default '.*'
        color index_author red default '.*'
        color index_number blue default
        color index_subject cyan default '.*'

        # New mail is boldened:
        color index brightyellow black "~N"
        color index_author brightred black "~N"
        color index_subject brightcyan black "~N"

        # Tagged mail is highlighted:
        color index brightyellow blue "~T"
        color index_author brightred blue "~T"
        color index_subject brightcyan blue "~T"

        # Flagged mail is highlighted:
        color index brightgreen default "~F"
        color index_subject brightgreen default "~F"
        color index_author brightgreen default "~F"

        # Other colors and aesthetic settings:
        mono bold bold
        mono underline underline
        mono indicator reverse
        mono error bold
        color normal default default
        color indicator brightblack white
        color sidebar_highlight red default
        color sidebar_divider brightblack black
        color sidebar_flagged red black
        color sidebar_new green black
        color error red default
        color tilde black default
        color message cyan default
        color markers red white
        color attachment white default
        color search brightmagenta default
        color status brightyellow black
        color hdrdefault brightgreen default
        color quoted green default
        color quoted1 blue default
        color quoted2 cyan default
        color quoted3 yellow default
        color quoted4 red default
        color quoted5 brightred default
        color signature brightgreen default
        color bold black default
        color underline black default

        # Regex highlighting:
        color header brightmagenta default "^From"
        color header brightcyan default "^Subject"
        color header brightwhite default "^(CC|BCC)"
        color header blue default ".*"
        color body brightred default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" # Email addresses
        color body brightblue default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" # URL
        color body green default "\`[^\`]*\`" # Green text between ` and `
        color body brightblue default "^# \.*" # Headings as bold blue
        color body brightcyan default "^## \.*" # Subheadings as bold cyan
        color body brightgreen default "^### \.*" # Subsubheadings as bold green
        color body yellow default "^(\t| )*(-|\\*) \.*" # List items as yellow
        color body brightcyan default "[;:][-o][)/(|]" # emoticons
        color body brightcyan default "[;:][)(|]" # emoticons
        color body brightcyan default "[ ][*][^*]*[*][ ]?" # more emoticon?
        color body brightcyan default "[ ]?[*][^*]*[*][ ]" # more emoticon?
        color body red default "(BAD signature)"
        color body cyan default "(Good signature)"
        color body brightblack default "^gpg: Good signature .*"
        color body brightyellow default "^gpg: "
        color body brightyellow red "^gpg: BAD signature from.*"
        mono body bold "^gpg: Good signature"
        mono body bold "^gpg: BAD signature from.*"
        color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]"
    '';
      binds = [
        { map = ["index" "pager"]; key = "x"; action = "modify-labels"; }
        { map = ["index" "pager"]; key = "i"; action = "noop"; }
        { map = ["index" "pager"]; key = "g"; action = "noop"; }
        { map = ["index"]; key = "\\Cf"; action = "noop"; }
        { map = ["index" "pager"]; key = "M"; action = "noop"; }
        { map = ["index" "pager"]; key = "C"; action = "noop"; }
        { map = ["index"]; key = "gg"; action = "first-entry"; }
        { map = ["index"]; key = "j"; action = "next-entry"; }
        { map = ["index"]; key = "k"; action = "previous-entry"; }
        { map = ["attach"]; key = "<return>"; action = "view-mailcap"; }
        { map = ["attach"]; key = "l"; action = "view-mailcap"; }
        { map = ["editor"]; key = "<space>"; action = "noop"; }
        { map = ["index"]; key = "G"; action = "last-entry"; }
        { map = ["pager" "attach"]; key =  "h"; action = "exit"; }
        { map = ["pager"]; key = "j"; action = "next-line"; }
        { map = ["pager"]; key = "k"; action = "previous-line"; }
        { map = ["pager"]; key = "l"; action = "view-attachments"; }
        { map = ["index"]; key = "U"; action = "undelete-message"; }
        { map = ["index"]; key = "L"; action = "limit"; }
        { map = ["index"]; key = "h"; action = "noop"; }
        { map = ["index"]; key = "l"; action = "display-message"; }
        { map = ["index" "query"]; key =  "<space>"; action = "tag-entry"; }
        { map = ["index" "pager"]; key =  "H"; action = "view-raw-message"; }
        { map = ["browser"]; key = "l"; action = "select-entry"; }
        { map = ["browser"]; key = "gg"; action = "top-page"; }
        { map = ["browser"]; key = "G"; action = "bottom-page"; }
        { map = ["pager"]; key = "gg"; action = "top"; }
        { map = ["pager"]; key = "G"; action = "bottom"; }
        { map = ["index" "pager" "browser"]; key = "d"; action = "half-down"; }
        { map = ["index" "pager" "browser"]; key = "u"; action = "half-up"; }
        { map = ["index" "pager"]; key =  "\\Cr"; action = "group-reply"; }
        { map = ["index" "pager"]; key =  "R"; action = "group-chat-reply"; }
        { map = ["index"]; key = "\031"; action = "previous-undeleted"; }
        { map = ["index"]; key = "\005"; action = "next-undeleted"; }
        { map = ["pager"]; key = "\031"; action = "previous-line"; }
        { map = ["pager"]; key = "\005"; action = "next-line"; }
        { map = ["editor"]; key = "<Tab>"; action = "complete-query"; }
        { map = ["editor"]; key = "\\Ct"; action = "complete"; }
      ];
      macros = [
        { map = ["index" "pager"]; key = ","; action = "<pipe-message>khard add-email<return>"; }
        { map = ["index"]; key = "X"; action = "<save-message>=Spam<enter>y"; }
        { map = ["index"]; key = "Ma"; action = "<save-message>=Archive<enter>y"; }
        { map = ["index"]; key = "A"; action = "<modify-labels-then-hide>+archive -unread -inbox<enter><mark-message>z<enter><change-folder>^<enter>'z"; }
        { map = ["index"]; key = "D"; action = "<delete-message>"; }
        { map = ["index" "pager"]; key =  "S"; action = "<sync-mailbox>!notmuch-hook<enter><mark-message>z<enter><change-folder>^<enter>'z"; }
        { map = ["index"]; key = "hi"; action = "<change-folder>~/.local/share/mail/ivi/Inbox<enter><change-vfolder>Inbox<enter>"; }
        { map = ["index"]; key = "hg"; action = "<change-folder>~/.local/share/mail/gmail/Inbox<enter><change-vfolder>Inbox<enter>"; }
        { map = ["index"]; key = "hf"; action = "<change-folder>~/.local/share/mail/family/Inbox<enter><change-vfolder>Inbox<enter>"; }
        { map = ["index"]; key = "\\\\"; action = "<vfolder-from-query>"; }
        { map = ["browser"]; key = "h"; action = "<change-dir><kill-line>..<enter>"; }
        { map = ["index"]; key = "\\Ck"; action = "<sidebar-prev><sidebar-open>"; }
        { map = ["index"]; key = "\\Cj"; action = "<sidebar-next><sidebar-open>"; }
        { map = ["index"]; key = "c"; action = "<change-folder>?/"; }
      ];
    };
  };
}