5

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?

2
  • 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? Commented Oct 5, 2011 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.
    – sharat87
    Commented Oct 5, 2011 at 9:21

1 Answer 1

5

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.

4
  • 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.
    – sharat87
    Commented Oct 5, 2011 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
    – sharat87
    Commented Oct 5, 2011 at 10:10
  • 1
    @ShrikantSharat this gives me the prompt of how to sort. Do I need to change folders to "All mail" first? How do I do that with the command?
    – Xu Wang
    Commented Apr 9, 2015 at 7:53
  • Using o I also get the sort prompt. For me the following command opens the message: mutt -e "push l~i${MSGID}\n<enter>"
    – nyi
    Commented Aug 11, 2018 at 16:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .