source "pass neomutt |"

# SMTP
set smtp_url = smtps://maximewack@smtp.free.fr:465
set smtp_pass = $my_free_pass

# Mailbox settings
set mbox_type = Maildir
set folder = ~/Mail/free
set postponed = +Drafts
set spoolfile = +Inbox
set record = +Inbox
set trash = +Trash
set header_cache = ~/.cache/neomutt
mailboxes = +Inbox
mailboxes = +Archives
mailboxes = +Drafts
mailboxes = +Trash
mailboxes = +Spam

# General options
set timeout = 1
set sleep_time = 0
set pager_stop
set beep_new
set mail_check = 1
unset mark_old
unset confirmappend
unset wait_key
set auto_tag
set menu_scroll
set menu_context = 20
set search_context = 20
unset resolve
set mailcap_path = ~/.config/neomutt/mailcap

# GPG Settings
set pgp_default_key=maximewack@free.fr
set pgp_auto_decode
set pgp_use_gpg_agent
set pgp_decode_command="gpg --status-fd=2 %?p?--pinentry-mode loopback --passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_verify_command="gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --status-fd=2 %?p?--pinentry-mode loopback --passphrase-fd 0? --no-verbose --quiet --batch --output - --decrypt %f"
set pgp_sign_command="gpg %?p?--pinentry-mode loopback --passphrase-fd 0? --no-verbose --batch --quiet --output - --armor --textmode %?a?--local-user %a? --detach-sign %f"
set pgp_clearsign_command="gpg %?p?--pinentry-mode loopback --passphrase-fd 0? --no-verbose --batch --quiet --output - --armor --textmode %?a?--local-user %a? --clearsign %f"
set pgp_encrypt_only_command="/usr/lib/neomutt/pgpewrap gpg --batch --quiet --no-verbose --output - --textmode --armor --encrypt -- --recipient %r -- %f"
set pgp_encrypt_sign_command="/usr/lib/neomutt/pgpewrap gpg %?p?--pinentry-mode loopback --passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - %?a?--local-user %a? --armor --sign --encrypt -- --recipient %r -- %f"
set pgp_import_command="gpg --no-verbose --import %f"
set pgp_export_command="gpg --no-verbose --armor --export %r"
set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-secret-keys %r"
set pgp_good_sign="^\\[GNUPG:\\] GOODSIG"
set pgp_check_gpg_decrypt_status_fd

# generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query
# Quit !
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query q exit
# Navigation
bind generic,alias,attach,browser,editor,index,compose,pgp,smime,postpone,query d previous-entry
bind generic,alias,attach,browser,editor,index,compose,pgp,smime,postpone,query s next-entry
bind pager d previous-line
bind pager s next-line

bind generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query D half-up
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query S half-down

bind generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query g noop
bind generic,alias,attach,browser,editor,index,compose,pgp,smime,postpone,query gg first-entry
bind generic,alias,attach,browser,editor,index,compose,pgp,smime,postpone,query G last-entry
bind pager gg top
bind pager G bottom

bind attach r view-attach
bind compose x detach-file
bind browser r select-entry
bind index r display-message
bind pager r view-attachments

bind generic,alias,attach,editor,compose,pager,pgp,smime,postpone,query t exit
bind browser t goto-parent
bind index t noop

bind pager v previous-entry
bind pager l next-entry

# Search
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,smime,postpone,query N search-opposite

# Tagging
macro generic,attach,browser,index,compose,pager,pgp,smime,postpone,query <space> "<tag-entry><next-entry>"
bind generic,index   tag-subthread
bind generic,index _ tag-pattern
bind index f limit
bind index ! flag-message

# Attach bindings
macro attach S "<save-entry><kill-line>/home/maxx/Downloads/"

# Index bindings
macro index,pager x "<delete-message><next-entry>"
macro index u "<undelete-entry><next-entry>"
bind index X delete-subthread
bind index U undelete-subthread
bind index za collapse-thread
bind index zA collapse-all
bind index zt collapse-all
bind index zT collapse-all
bind index zr collapse-all
bind index zR collapse-all

# Mail actions
bind index T mail
bind pager T compose-to-sender
bind index,pager R reply
bind index,pager A group-reply
bind index,pager F forward-message
bind index,pager B bounce-message
macro index,pager I "<pipe-message>khard add-email<return>" "add sender email to khard"

macro index \'i "<change-folder>=Inbox<enter>" "Go to inbox"
macro index \'a "<change-folder>=Archives<enter>" "Go to archives"
macro index \'t "<change-folder>=Trash<enter>" "Go to trash"
macro index \'d "<change-folder>=Drafts<enter>" "Go to drafts"
macro index \'s "<change-folder>=Sent<enter>" "Go to sent"

# Move to archives and retreive into inbox
macro index m "<sync-mailbox><shell-escape>mbsync free<enter><sync-mailbox>" "Refresh"
bind index,pager M noop
macro index Ma "<tag-prefix><save-message>=Archives\n" "Move to Archives"
macro pager Ma "<save-message>=Archives\n<next-entry>" "Move to Archives"
macro index,pager Mi ":set delete=yes\n<tag-prefix><save-message>=Inbox\n<sync-mailbox>:set delete=ask-yes\n" "Retreive to Inbox"

# Completion in editor
bind editor <Tab> complete-query
bind editor ^T    complete

# Compose settings
set editor = nvim
set edit_headers
set autoedit
set query_command= "echo %s | xargs khard email --parsable --"
set realname = 'Maxime Wack'
set from = maximewack@free.fr
set use_from
set include
# set text_flowed = yes
# set reflow_text = yes
set wrap
unset markers
set send_charset = "utf-8"

## Index
set sort = threads
set sort_aux = last-date-received
set strict_threads
set index_format = "%?X?📎&  ?%S%?M?%2M+&   ? %s (%c) %*  %25F %<[y?%<[d?%10[%H:%M]&%10[%y-%m-%d]>&%[%Y-%m-%d]>"

# Index colors
color index default default '.*'
color index_flags blue default '.*'
color index_subject green default '.*'
color index_size cyan default
color index_author yellow default '.*'
color index_date red default
# Bold new
color index brightdefault default '~N'
# Inverted tagged
color index default brightblack '~T'
color index_author yellow brightblack '~T'
color index_subject green brightblack '~T'
color index_flags blue brightblack '~T'
# Shaded for deleted
color index black default '~D'
color index_author black default '~D'
color index_subject black default '~D'
color index_flags black default '~D'
# Red subject for important
color index_subject red default '~F'
# Thread size in magenta
color index_collapsed magenta default

# Pager colors
set header_color_partial
ignore User-Agent X-Mailer
color header brightblack default 'Date:.*'
color header brightblack default 'to:.*'
color header brightblack default 'Cc:.*'
color header brightblack default '^[^:]+:'
color body black default '^>.*'
color attachment blue default

# Sidebar
bind index <up> sidebar-prev
bind index <down> sidebar-next
bind index <right> sidebar-open
set sidebar_visible
set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
set sidebar_width = 20
set mail_check_stats

