有时我收到的电子邮件附件的 mimetype 不在我的 mailcap 文件中。要从 mutt 打开此类附件,我通常从列表中选择附件,点击s
将文件保存到/tmp
,然后使用!
shell 命令使用任何适合的应用程序打开保存的文件。
是否可以使用 mutt 宏自动执行此操作,它只是将选定的附件保存到/tmp
,查询应用程序名称,然后使用此应用程序打开保存的文件?
我会回答我自己的问题。以下条目.muttrc
符合我的要求:
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\
"
说明(逐行):
O
附件模式中的键/tmp/mutt-attach
如果文件存在则删除/tmp/mutt-attach
/tmp/mutt-attach &
并转到行首 (^A
)然后我可以简单地输入我要使用的程序并按回车,这将在后台打开选定的附件。
或者,如果您想始终打开同一个程序(在我的情况下为 firefox):
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>\
"