I have the value of the Message ID header of a particular message in my mutt's inbox and I want to open it with a one shot mutt command, read and close.

Currently, I open mutt, do a with ~i <the-message-id>, which lists just one message, and then open it with o (My keybinding to open a message).

Is there a way I can create a shell function/script to enable a usage like

mutt-open-message <the-message-id>

and the message opens up in mutt? I tried playing around with the -e option of mutt but couldn't get this functionality working.

Any ideas on this?

link|improve this question

80% accept rate
Do I understand you correctly that mutt-open-message should just output the message and directly return without any user interaction? Or do you want to remote control and already running mutt instance? – maxschlepzig Oct 5 '11 at 8:28
@maxschlepzig, you understand correct. I only need to read the message, whether it be by opening mutt or less or vim whatever pager. Not controlling an already running mutt instance. – Shrikant Sharat Oct 5 '11 at 9:21
feedback

1 Answer

Not the prettiest solution but this seems to work (using mutt 1.5.20), with a message ID taken from my inbox in $MSGID:

mutt -e "macro index - 'l~i${MSGID}'; push -\n"

If you already use the '-' key for something in the index choose a different key instead.

link|improve this answer
Slightly modified, to open the message directly: mutt -e "macro index - 'l~i${MSGID}'; push -\no". Ofcourse one would use \n in place of the o to open the message. – Shrikant Sharat Oct 5 '11 at 9:28
Ha! Thanks for this answer, I came to know about push. A macro isn't really needed actually. Just mutt -e "push l~i${MSGID}\no" works just fine – Shrikant Sharat Oct 5 '11 at 10:10
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.