I'd like the following configuration for my mutt.

If the email is in the foo folder in mutt, then the s key in the attachment view should save the attachment to the ~/bar directory.

In any other mailbox, the s key should be mapped to the normal <save-entry> command in the attachment view.

I tried to use a folder-hook to map a new macro like this:

folder-hook foo "macro attach s <save-entry><kill-line>~/bar/<enter>"

But, this command does not unset the macro as soon as I move to a different mailbox. How can I accomplish this unsetting of the macro for all other folders?


Multiple folder-hooks are always executed in order.

So you must first provide a configuration that matches all folders; then configurations for particular folders.

In your case, first define the default binding for all folders, and then the particular macro for the foo folder:

folder-hook . "macro attach s <save-entry>"
folder-hook foo "macro attach s <save-entry><kill-line>~/bar/<enter>"

I found the default binding by pressing ? in the attachment menu and searching for s.

This is mentioned in mutt documentation for folder-hook:

...is not restored to its previous value when reading a different mailbox. To specify a default command, use the pattern “.” before other folder-hooks adjusting a value on a per-folder basis because folder-hooks are evaluated in the order given in the configuration file.

  • You're right. I should RTFM more clearly. I had missed out on the . representing all folders and was looking for a regex like expression to get the things done. – darnir Nov 2 '14 at 5:58
  • . is actually a regex; it matches any single character (which all folder names have). I use . a lot for un-limiting message list views (L . <enter>). – Juancho Nov 2 '14 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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