From 18af7b3f3ec1c47227d7757477226a13e339c59d Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Mon, 9 May 2022 10:03:40 +0200 Subject: [PATCH] Use ROFI to search mail --- mail.org | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/mail.org b/mail.org index 56c8a38..e4129fe 100644 --- a/mail.org +++ b/mail.org @@ -734,8 +734,10 @@ macro attach,compose,index,pager \cw "\ *** Searching using Mu #+begin_src conf -macro index,pager \Cf "mu find --clearlinks --format=links --linksdir=~/.mail/search " \ - "mu find" +macro index,pager \Cf "$HOME/.config/neomutt/bin/search_mail.sh~/.mail/search" \ + "test" +# macro index,pager \Cf "mu find --clearlinks --format=links --linksdir=~/.mail/search " \ +# "mu find" macro index,pager gf "~/.mail/search" \ "mu find results" #+end_src @@ -931,7 +933,10 @@ macro index,pager D \ **** Signature #+begin_src conf :tangle ~/.config/neomutt/accounts/esrf.signature :comments none :padline no -Thomas Dehaeze +Thomas DEHAEZE +Mechatronics Engineer +ESRF - The European Synchrotron +Tel: +33 (0)4.76.88.22.34 #+end_src This empty code block is used to add a new line after signature #+begin_src conf :tangle ~/.config/neomutt/accounts/esrf.signature :comments none :padline no @@ -1129,14 +1134,35 @@ set abort_noattach_regex = "\\<(attach(|ed|ments?)|(attaché|attachés|attache|a #+end_src ** Scripts and other config files -*** Send Mail Script :PROPERTIES: -:header-args: :tangle ~/.config/neomutt/bin/send_mail.sh -:header-args+: :comments both :mkdirp yes +:header-args: :comments both :mkdirp yes :header-args+: :shebang "#!/usr/bin/env bash" :END: -#+begin_src bash +*** Search Mail +#+begin_src bash :tangle ~/.config/neomutt/bin/search_mail.sh +arg_subject=$(rofi -p "Search" -dmenu) + +arg_from=$(rofi -p "From" -dmenu) +if [ ! -z "$arg_from" ]; then + arg_from="from:${arg_from}" +fi + +arg_to=$(rofi -p "To" -dmenu) +if [ ! -z "$arg_to" ]; then + arg_to="to:${arg_to}" +fi + +arg_mime=$(echo -e "\napplication/pdf\nimage/*\nvideo/*" | rofi -i -p "Mime" -dmenu) +if [ ! -z "$arg_mime" ]; then + arg_mime="mime:${arg_mime}" +fi + +mu find --clearlinks --format=links --linksdir=~/.mail/search "${arg_from} ${arg_to} ${arg_mime} ${arg_subject}" +#+end_src + +*** Send Mail Script +#+begin_src bash :tangle ~/.config/neomutt/bin/send_mail.sh msmtp -a $1 ${@:2} && \ if [ $TMUX ]; then tmux split -v -l 1 mbsync $1-Sent && tmux select-pane -U @@ -1146,13 +1172,7 @@ msmtp -a $1 ${@:2} && \ #+end_src *** Sync Mail Script -:PROPERTIES: -:header-args: :tangle ~/.config/neomutt/bin/get_new_mail.sh -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - -#+begin_src bash +#+begin_src bash :tangle ~/.config/neomutt/bin/get_new_mail.sh if [ $TMUX ]; then tmux split -v -l 1 checkmail $1 && tmux select-pane -U else @@ -1161,13 +1181,7 @@ fi #+end_src *** Openfile Scripts -:PROPERTIES: -:header-args: :tangle ~/.config/neomutt/bin/openfile.sh -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - -#+begin_src bash +#+begin_src bash :tangle ~/.config/neomutt/bin/openfile.sh base=$(basename "$1") ext="${base##*.}"