diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 175ed68b..c73e2b03 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -276,8 +276,9 @@ globalkeys = awful.util.table.join( awful.key({ modkey, }, "p", function () awful.util.spawn("zathura") end), -- Mail user agent - awful.key({ modkey, }, "m", function () awful.util.spawn(term .. "mutt") end), - awful.key({ }, "XF86Mail", function () awful.util.spawn(term .. "mutt") end), + -- Mutt needs to be started in the folder where you want to save attachments. + awful.key({ modkey, }, "m", function () awful.util.spawn(term .. "sh -c 'cd ~/temp && mutt'") end), + awful.key({ }, "XF86Mail", function () awful.util.spawn(term .. "sh -c 'cd ~/temp && mutt'") end), -- Web browser awful.key({ modkey, }, "w", function () awful.util.spawn_with_shell("dwb 2>>/tmp/dwb" .. uid .. ".log") end), diff --git a/.mutt/account-example b/.mutt/account-example index 2e50e6bb..35a42bf9 100644 --- a/.mutt/account-example +++ b/.mutt/account-example @@ -1,41 +1,40 @@ -# -*- mode:sh -*- -## Mutt -- Personal account +## Mutt -- Gmail account sample set imap_user=user@gmail.com set imap_pass=$my_pw_personal set from=$imap_user set hostname="gmail.com" -set folder = imaps://user@imap.gmail.com/ -set spoolfile = +INBOX -set postponed = +[Google Mail]/Drafts +set folder=imaps://user@imap.gmail.com/ +set spoolfile=+INBOX +set postponed=+[Gmail]/Drafts unset record ## Google does it automatically, so we do not want duplicates. ## Send options. -set realname='User X' +set realname='John Doe' set smtp_url=smtps://user:$imap_pass@smtp.gmail.com -set ssl_force_tls = yes +set ssl_force_tls=yes unset ssl_starttls -## Signatures -## Note that fortune-mod must be installed to use fortune command. -set signature="cat ~/.mutt/real_name && cat ~/.mutt/asciiribbon && fortune -s|" +## Signature with a random 'fortune'. +set signature="cat ~/.mutt/real_name && fortune -s |" ## Sidebar mailboxes separator workaround. -mailboxes "+A-- User -----------" +mailboxes "+A-- Personal -------" ## Hooks account-hook $folder "set imap_user=user@gmail.com imap_pass=$my_pw_personal" ## Reset PGP send-hooks. ## TODO: unhook does not seem to be working. unhook send-hook +send-hook . 'unset pgp_autosign; unset pgp_autoencrypt' -## Remove your e-mail from group-reply. +## Remove own e-mail address from group-reply. alternates $imap_user ## Gmail-specific macros: ## Prevent Gmail from deleting to 'All Mail', move it to Trash instead. -# macro index d ";s+[Gmail]/Trash" "Move to Gmail's Trash" -# macro pager d "s+[Gmail]/Trash" "Move to Gmail's Trash" +macro index d ";s+[Gmail]/Trash" "Move to Gmail's Trash" +macro pager d "s+[Gmail]/Trash" "Move to Gmail's Trash" ## Undelete messages. -# macro index u ";s+INBOX" "Move to Gmail's INBOX" -# macro pager u "s+INBOX" "Move to Gmail's INBOX" +macro index u ";s+INBOX" "Move to Gmail's INBOX" +macro pager u "s+INBOX" "Move to Gmail's INBOX" diff --git a/.mutt/colors.classic.sh b/.mutt/colors.classic old mode 100755 new mode 100644 similarity index 97% rename from .mutt/colors.classic.sh rename to .mutt/colors.classic index 93ebad66..18e9d8b9 --- a/.mutt/colors.classic.sh +++ b/.mutt/colors.classic @@ -1,7 +1,5 @@ -#!/bin/sh ## 256 colors classic theme -cat < 'source ~/.mutt.d/$my_ac_personal!' -# macro index,pager 'source ~/.mutt.d/$my_ac_work!' - ## Store passwords as follows in .mutt.pwds: -# set my_pw_account = foo +# set my_pw_personal = foo +# set my_pw_work = foo ## ## CCRYPT: ## $ ccencrypt .mutt.pwds @@ -116,29 +100,46 @@ set strict_threads = yes ## Encrypt them with: ## $ gpg2 -e -r ".mutt.pwds" +## 'accountrc' should contain the following config: + +## Fetch passwords +# source "ccat ~/.mutt.pwds.cpt |" +## Or +# source "gpg2 -dq ~/.mutt.pwds.gpg |" +## +## Source accounts. Default account is last. +# source "~/.mutt.d/personal" +# folder-hook $folder 'source ~/.mutt.d/personal' +# source "~/.mutt.d/work" +# folder-hook $folder 'source ~/.mutt.d/work' +## +## You can add an optional binding to switch mailboxes: +# macro index,pager 'source ~/.mutt.d/personal!' +# macro index,pager 'source ~/.mutt.d/work!' + source "~/.mutt.d/accountrc" ################################################################################ -## Aliases +## Aliases. -## Mutt native support +## Mutt native support. # set alias_file = "~/.mutt.d/aliases" # set sort_alias = alias # set reverse_alias = yes # source $alias_file -## Abook +## Abook. ## We redirect the error stream in case the config file in not compatible with -## current abook bersion. -set query_command= "abook --mutt-query '%s' 2>/dev/null" -macro index,pager a "abook --add-email-quiet" "Add this sender to Abook" -bind editor complete-query +## current Abook version. +set query_command="abook --mutt-query '%s' 2>/dev/null" +macro index,pager a "abook --add-email-quiet" "Add this sender to Abook" +bind editor complete-query ################################################################################ -## Keys +## Key bindings. -## Security issue: if enter-command is available from the GUI, it is possible to -## see the password unencrypted. We disable it for this reason. Every command +## Security issue: if 'enter-command' is available from the GUI, it is possible +## to see the password unencrypted. We disable it for this reason. Every command ## that the user intends to use must be bound to a key in advance, otherwise it ## will never be accessible. bind generic,alias,attach,browser,editor,index,compose,pager,pgp,postpone ':' noop @@ -149,7 +150,7 @@ macro attach 'V' "cat >~/.cache/mutt/mutt-attach.mail && $BROWSER ~/ ## Remap bounce-message function to "B" bind index B bounce-message -## Always reply to group +## Always reply to group. bind index,pager r group-reply ## Fix the 'change-dir' issue with multiple accounts. When change-dir was called @@ -168,8 +169,32 @@ bind index "^" imap-fetch-mail ## Changed kbs=^H to kbs=\177, then: ## $ tic -x termbs.src +## Vi/Emacs bindings. +bind pager j next-line +bind pager k previous-line +bind attach,index,pager \CD next-page +bind attach,index,pager \CU previous-page +bind attach,index,pager ? search-reverse +bind attach,index,pager h help +bind attach,index,pager \Ch display-toggle-weed +bind attach,index,pager N search-opposite +bind index n toggle-new +bind pager n mark-as-new +bind index x collapse-thread +bind index X collapse-all +bind attach,index,pager \CV next-page +bind attach,index,pager v previous-page +bind pager g top +bind pager G bottom +bind pager < top +bind pager > bottom +bind attach,index g first-entry +bind attach,index G last-entry +bind attach,index < first-entry +bind attach,index > last-entry + ################################################################################ -## Custom headers for outgoing mail +## Custom header for outgoing mail. ## Undo any custom headers that may have been put in by the global Muttrc # unmy_hdr * @@ -187,14 +212,14 @@ my_hdr X-Info: Simplicity is the ultimate sophistication. # my_hdr X-Operating-System: `uname -s`, kernel `uname -r` ## This header only appears to MS Outlook users -# my_hdr X-Message-Flag: WARNING!! Outlook sucks! +# my_hdr X-Message-Flag: Warning: Outlook sucks! ## Custom Mail-User-Agent ID. -set user_agent = yes +set user_agent=yes # my_hdr User-Agent: Every email client sucks, this one just sucks less. ################################################################################ -## Themes +## Theme. ## Index format ## We use my_col_* to get dynamic column size. @@ -202,28 +227,31 @@ set user_agent = yes # set index_format="%?M?_%M_ ?%Z %2C %.13d (%-68.68F) %-68.68s %?M?_%M_&(%c/%l?" set date_format="%y-%m-%d %T" -folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %?M?<%M> ?%-$my_col_subject.${my_col_subject}s"' -folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %?M?<%M> ?%-$my_col_subject.${my_col_subject}s"' +set my_index_format_pre='set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}' +set my_index_format_post=' (%-4.4c) %?M?<%M> ?%-$my_col_subject.${my_col_subject}s"' + +folder-hook .*[sS]ent.* "$my_index_format_pre"t"$my_index_format_post" +folder-hook ! .*[sS]ent.* "$my_index_format_pre"F"$my_index_format_post" ## Original status_format, with dash line removed. set status_format="-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?] (%s/%S) %> (%P) " -## This will redraw screen while refreshing the new cols value. Since there -## seems to be no way to check what folder is the current, this will not behave -## like the above hooks and will set the index_format correctly for non Sent -## folders only. -macro pager \CL 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"' +## This will redraw screen and justify the index. +macro index,pager \CL "$my_index_format_pre"F"$my_index_format_post" -## Colors -# source "/usr/share/doc/mutt/samples/colors.default" -# source "/usr/share/doc/mutt/samples/colors.linux" -# source "~/.mutt/colors.classic.sh|" -source "~/.mutt/colors.zenburn.sh|" -source "~/.mutt/colors.fallback.sh|" -source "~/.mutt/mutt.colors" +## Set color variables from a theme. +# source "~/.mutt/colors.classic" +source "~/.mutt/colors.zenburn" + +## Fallback for terminals without 256 colors. This needs to be a shell script so +## that it can check for terminal capabilities. +source "~/.mutt/colors.fallback.sh |" + +## Apply theme. +source "~/.mutt/theme" ################################################################################ -## Sidebar +## Sidebar. ## We use a script to test if sidebar is installed. Needs to be loaded _after_ ## the theme. diff --git a/.mutt/cachepurge.sh b/.mutt/purgecache.sh similarity index 79% rename from .mutt/cachepurge.sh rename to .mutt/purgecache.sh index 1f79c44b..8dd078e5 100755 --- a/.mutt/cachepurge.sh +++ b/.mutt/purgecache.sh @@ -1,13 +1,14 @@ #!/bin/sh -## Purge old message in Mutt's message cache. +## Purge old messages in Mutt's message cache. +## "$1" is cache location. ## This is intended to be run at startup, but can be run manually anytime. ## It should not output anything to stdout. ## In KB. CACHE_LIMIT=51200 -cd ~/.cache/mutt_msg 2>/dev/null +cd "$1" 2>/dev/null [ $? -ne 0 ] && exit [ $(du -s . | cut -f1 -d' ') -lt $CACHE_LIMIT ] && exit diff --git a/.mutt/sidebar.sh b/.mutt/sidebar.sh index b6408467..46608b97 100755 --- a/.mutt/sidebar.sh +++ b/.mutt/sidebar.sh @@ -20,10 +20,7 @@ bind index,pager \CP sidebar-prev bind index,pager \CN sidebar-next bind index,pager \CO sidebar-open -## Toggle sidebar visibility -# macro index b 'toggle sidebar_visible' -# macro pager b 'toggle sidebar_visible' -## Prevent messy output +## Toggle sidebar visibility. Screen might get messed up, hence the refresh. macro index b 'toggle sidebar_visible' macro pager b 'toggle sidebar_visible' EOF diff --git a/.mutt/mutt.colors b/.mutt/theme similarity index 100% rename from .mutt/mutt.colors rename to .mutt/theme diff --git a/.scripts/homeclean b/.scripts/homeclean index 6fad5baf..b0e32eab 100755 --- a/.scripts/homeclean +++ b/.scripts/homeclean @@ -7,7 +7,6 @@ set -- "$HOME/.cache/dwb" \ "$HOME/.cache/emacs/ido.last" \ "$HOME/.cache/emacs/saveplace" \ "$HOME/.cache/mutt" \ - "$HOME/.cache/mutt_msg" \ "$HOME/.cache/rtorrent" \ "$HOME/.cache/zsh" \ "$HOME/.cmus/autosave" \ diff --git a/.scripts/homeinit b/.scripts/homeinit index 287f7ba5..f29000d8 100755 --- a/.scripts/homeinit +++ b/.scripts/homeinit @@ -20,7 +20,8 @@ fi if command -v mutt >/dev/null 2>&1; then echo "==> Mutt" [ -d "$SOURCEDIR" ] && ln -snf "$SOURCEDIR/mails" "$HOME/.mutt.d" - mkdir -p "$HOME/.cache/mutt/" + mkdir -p "$HOME/.cache/mutt/headers" + mkdir -p "$HOME/.cache/mutt/messages" echo fi