"Open attachment with" macro in mutt mail client

Sometimes I get email attachments whose mimetypes are not in my mailcap file. To open such attachments from mutt, I usually select the attachment from the list, press s to save the file to /tmp , and then use ! To open a saved file with any application suitable using the shell command.

Is it possible to automate this with the mutt macro, which simply saves the selected attachment in /tmp , requests for the application name and then opens the saved file with this application?

+6
source share
2 answers

I will answer my question. The following entry in .muttrc does what I want:

 macro attach O \ "\ <enter-command>unset wait_key<enter>\ <shell-escape>rm -f /tmp/mutt-attach<enter>\ <save-entry><kill-line>/tmp/mutt-attach<enter>\ <shell-escape> /tmp/mutt-attach &^A\ " 

Description (line by line):

  • match macro with key O in attachment mode
  • disable "Press any key to continue ..."
  • delete the file /tmp/mutt-attach , if it exists
  • save the selected entry to /tmp/mutt-attach
  • run the shell command, type /tmp/mutt-attach & and go to the beginning of the line ( ^A )

Then I can just type in the program that I want to use and press enter to open the selected attachment in the background.

+8
source

Or if you want to always open the same program (firefox in my case):

 macro attach F \ "\ <enter-command>unset wait_key<enter>\ <shell-escape>rm -f /tmp/mutt-attach<enter>\ <save-entry><kill-line>/tmp/mutt-attach<enter>\ <shell-escape>firefox /tmp/mutt-attach &<enter>\ " 
0
source

All Articles