Para começar, você pode usar uma macro como essa para pular automaticamente para a nova mensagem:
macro index .n "<next-unread-mailbox><enter><next-new-then-unread><enter>" "Go to new mail"
Note, entretanto, que se não houver novas mensagens apenas Enter a tecla será pressionada e a mensagem atual será aberta.
Como alternativa, se Maildir
for usado, poderíamos usar um script ~/bin/mutt-new.sh
que verificaria se há novos e-mails:
#!/usr/bin/env sh
if [ "$(find "$HOME"/.muttmail/box1/new -type f -printf '\n' | wc -l)" -eq 0 ]
then
printf "I think there's no new mail\n" >&2
printf "Press [ENTER] to continue\n" >&2
read -r _
exit 1
fi
echo 'push <next-unread-mailbox><enter><next-new-then-unread><enter>'
Adicione isso a ~/.muttrc
:
macro index .n "!~/bin/mutt-new.sh" "Go to new"
EDITAR:
Que tal isto: o seguinte script irá primeiro verificar se há novas mail na caixa de correio atual:
#!/usr/bin/env sh
cur_mbox=${1/=/}
echo "$1" >> /tmp/PAR
echo "$cur_mbox" >> /tmp/PAR
if [ ! "$(find "$HOME"/.muttmail/"$cur_mbox"/new -type f -printf '\n' | wc -l)" -eq 0 ]
then
printf "There is new mail in this mailbox\n" >&2
printf "Press [ENTER] to continue\n" >&2
read -r _
echo 'push <next-new-then-unread><enter>'
elif [ ! "$(find "$HOME"/.muttmail/ -type d -name new -exec ls {} \; | wc -l)" -eq 0 ]
then
printf "There is new mail in other mailboxes\n" >&2
printf "Press [ENTER] to continue\n" >&2
read -r _
echo 'push <next-unread-mailbox><enter><next-new-then-unread><enter>'
else
printf "I think there's no new mail\n" >&2
printf "Press [ENTER] to continue\n" >&2
read -r _
exit 1
fi
Adicione isso a ~/.muttrc
:
folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; set record=$my_oldrecord'
folder-hook . 'macro index .n "<enter-command>source \"~/bin/mutt-new.sh $my_folder |\"<return>" "Go to new"'
EDITAR:
Você disse:
This is sub-optimal anyway, because if I have a new message, quit mutt, then open mutt again, this won't move me to the mailbox containing the "new" messages. (Presumably the mailbox is not unread any more.)
Isso pode ser corrigido por:
set mark_old=no