diff --git a/astroid/hooks/move2inbox b/astroid/hooks/move2inbox new file mode 100755 index 0000000..535b61d --- /dev/null +++ b/astroid/hooks/move2inbox @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Moves a file to the INBOX directory +# +# $1 = message id + +MAIL_ROOT=`notmuch config get database.path` +DIR_INBOX="INBOX" +LOG="/home/$USER/.config/astroid/hooks/hook.log" + +ID=$1 +FILE=$(notmuch search --exclude=false --output=files id:"${ID}") # get actual file path of MID + +if ! $(echo ${FILE} | grep -q "${MAIL_ROOT}/${DIR_INBOX}/"); then # if mail is not in INBOX already + mv "${FILE}" "${MAIL_ROOT}/${DIR_INBOX}/cur/" + echo "[move2inbox] [SUCCESS] moved ${FILE} to ${MAIL_ROOT}/${DIR_INBOX}/cur/" >> $LOG +else + echo "[move2inbox] [ERROR] already in \"${DIR_INBOX}\" directory: ${FILE}" >> $LOG +fi diff --git a/astroid/keybindings b/astroid/keybindings index f274897..e683100 100644 --- a/astroid/keybindings +++ b/astroid/keybindings @@ -41,3 +41,4 @@ thread_view.toggle_unread=u # Toggle the unread tag on the message, default: N # HOOKS thread_view.run(hooks::unspam %2 %1)=M-s thread_view.run(hooks::delmail %2 %1)=M-d +thread_view.run(hooks::move2inbox %2 %1)=M-i