From a4918d2e2c10c85e04ba7375b1aaeec271483f23 Mon Sep 17 00:00:00 2001 From: masterzu Date: Mon, 20 Jan 2020 15:48:33 +0100 Subject: [PATCH] mutt configuration --- .mutt/mutt_ldap.sh | 30 ++++ .mutt/muttrc | 205 +++++++++++++++++++++++++++ .mutt/{colors-mutt => muttrc-colors} | 0 3 files changed, 235 insertions(+) create mode 100755 .mutt/mutt_ldap.sh create mode 100644 .mutt/muttrc rename .mutt/{colors-mutt => muttrc-colors} (100%) diff --git a/.mutt/mutt_ldap.sh b/.mutt/mutt_ldap.sh new file mode 100755 index 0000000..00f0216 --- /dev/null +++ b/.mutt/mutt_ldap.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function usage { + echo $0: no search string given + exit 1 +} + +test -z "$1" && usage +search="$1" + +resu="" +do_search(){ + + local LDAPURI="$1" + local LDAPBASE="$2" + local search="$3" + ldapsearch -x -LLL -H $LDAPURI -b $LDAPBASE "(|(uid=~$search)(cn~=$search)(mail~=$search))" mail cn 2>/dev/null | + awk 'BEGIN { n1=1; cn=""; mail="" } /^cn:/ { cn = $2 " " $3 " " $4 " " $5 " " $6 } /^mail:/ { mail = $2 } /^$/ { resu[n1] = mail "\t" cn; mail=""; cn=""; n1++ } END { for (v in resu) print resu[v] } ' | + sed '/^$/d' +} + +# search in labo ldap + in university +resu="$(do_search ldap://ldap.dalembert.upmc.fr o=ijlrda "$search") +$(do_search ldap://ldap.upmc.fr ou=People,dc=upmc,dc=fr "$search")" + +echo $(echo "$resu" | wc -l) "address(es) found:" +echo "$resu" + + + diff --git a/.mutt/muttrc b/.mutt/muttrc new file mode 100644 index 0000000..d88cbb2 --- /dev/null +++ b/.mutt/muttrc @@ -0,0 +1,205 @@ +# mutt config +# +# from https://github.com/Nelyah/dotfiles/blob/master/.mutt/settings + +# +# define realname, from, hostname and alternates +source ~/.mutt/muttrc-me + +set use_envelope_from=yes + +set reverse_name +set reverse_realname + + +# +# paths +# +# set folder = ~/.mail # mailbox location -- set in accounts files +set alias_file = ~/.mutt/alias # where to store aliases +set header_cache = ~/.mutt/cache/headers # where to store headers +set message_cachedir = ~/.mutt/cache/bodies # where to store bodies +set certificate_file = ~/.mutt/certificates # where to store certs +set tmpdir = ~/.mutt/temp # where to keep temp files +set print_command = lp +set ispell = "aspell check" + +# +# general +# + +set mail_check=90 # check mail every (s) +set timeout=15 # wait only (s) max +set editor='vim "+set spelllang=fr"' +set nowait_key + +# text/html .... +alternative_order text/plain text/html +auto_view text/html + + +# status format +# default is = "-%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)---" +set status_format = "-%r-%v@%h: %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)---" +# +# pager format +# default is "-%Z- %C/%m: %-20.20n %s%* -- (%P)" +set pager_format = "-%Z- %C/%m: from <%n> « %s »%* -- (%P)" + +# +# index +# +# index format dynamic change +# from https://muttmua.gitlab.io/mutt/manual-dev.html#index-format-hook +set index_format="%4C %Z %?H?[%H]? %-10@date@ %-30.30L (%?l?%4l&%4c?) %s" +index-format-hook date "~d<1d" "%[%H:%M]" +index-format-hook date "~d<2d" "hier %[%H:%M]" +index-format-hook date "~d<5d" "%[%a %H:%M]" +index-format-hook date "~d<1m" "%[%a %d]" +index-format-hook date "~d<1y" "%[%d %b]" +index-format-hook date "~A" "%[%m/%Y]" + +set sort = threads # default sorting +set sort_aux = last-date-received # second sorting + + +# +# aliases +# +source ~/.mutt/alias + +# +# keybinding +# +bind index '"' what-key # print key code -- ctrl+g to quit +bind index G imap-fetch-mail # force fetch new email +bind index K previous-unread +bind index J next-unread +bind pager half-up +bind pager half-down + + +# +# Macros +# + +# save messages +macro index >S =SPAM 'save to SPAM' +macro index >V =VLAN 'save to VLAN' +macro index >D =diffusion 'save to diffusion' +macro index >C =CSSI 'save to CSSI' +macro index >I =IMPRIMANTES 'save to IMPRIMANTES' +macro index >L =logwatchs 'save to logwatchs' + +# urlview +# macro index,pager \cb "|urlview\n" "urlview to extract URLs" +macro index,pager \cb "urlscan" "open URL in BROWSER" + +# limit to new/old/flag messages +macro index ,n "(~N|~O|~F)" "view new/flag" +macro index ,a "~A" "view all" + +# get new messages by default +folder-hook . push ,n + +# urlscan +# macro index,pager \cb "urlscan" "urlscan to extract URLs" +# macro attach,compose \cb "urlscan" "urlscan to extract URLs" +# macro index,pager \cc "urlscanchrome" "urlscan to extract URLs (chrome)" +# macro attach,compose \cc "urlscanchrome" "call urlscan to extract URLs out of a message" + +# identities +macro compose \cf "^Umoi\_" "Select from" + +# +# notmoch-mutt from debian +# from /etc/Muttrc.d/notmuch-mutt.rc +# +macro index \ +"set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ +notmuch-mutt -r --prompt search\ +`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`\ +set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ + "notmuch: search mail" + +macro index \ +"set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ +notmuch-mutt -r thread\ +`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`\ +set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ + "notmuch: reconstruct thread" + +macro index \ +"set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ +notmuch-mutt tag -- -inbox\ +set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ + "notmuch: remove message from inbox" + +# +# spam detection - champs %H +# +spam "X-j-chkmail-Status: Spam (.*)" "ju/%1" +spam "X-Spam-Status: Yes" "sa" +spam "X-Amavis-Spam-Status: Yes" "am" +spam "X-Renater-SpamScore: ([1-9][0-9]*)" "re/%1" +set spam_separator="|" + +# +# Messages +# +set rfc2047_parameters # decoded some +set send_charset = "us-ascii:utf-8" # UTF stuff +set assumed_charset = "utf-8" +set charset = "utf-8" +set date_format = "%d %b %Y a %H:%M:%S %Z" +set attribution_locale = "fr_FR.UTF-7" +set attribution="Le %d, %n a écrit :" + +# +# headers +# +ignore * +unignore from date subject to cc User-Agent Content-Length +unignore organization organisation x-mailer: x-newsreader: x-mailing-list: +unignore posted-to: List-Id: +unignore X-j-chkmail-Status: X-Spam-Status: X-Amavis-Spam-Status: X-Renater-SpamScore: +# reset header order +unhdr_order * +hdr_order Date: Subject: From: From To: Cc: User-Agent: x-mailer: posted-to: List-Id: x-mailing-list: Content-Length: X-*: + +# pager +set pager_stop # dont exit at the end of the message with + +# +# Listes +# + +subscribe .*@listes.upmc.fr +subscribe .*@lists.debian.org +subscribe .*@pmichaud.com +subscribe .*@services.cnrs.fr +subscribe .*@listes.fercsup-cgt.org + +# +# Colors +# +source $HOME/.mutt/muttrc-colors + +# +# from https://github.com/Nelyah/dotfiles/blob/master/.mutt/settings +# use to change +macro generic \Cx| "source" +macro generic \Cx& "macro index \\t \"\\Cx" +macro index "\Cx1" +# macro generic \Cx0 "\Cx| ~/.mutt/accounts/archive\"\n\Cx&1\"!" + +# define accounts and Fx links +# +smtp_url, sll_force_tls, ssl_starttls +source $HOME/.mutt/muttrc-accounts + +# +# Query : ldap +# +# Use with Ctrl+t +set query_command = "$HOME/.mutt/mutt_ldap.sh %s" + diff --git a/.mutt/colors-mutt b/.mutt/muttrc-colors similarity index 100% rename from .mutt/colors-mutt rename to .mutt/muttrc-colors