Save Attachments to Special Folder in Mutt
Problem: How to save attachments in mutt?
No built-in solution for save multiple attachments to special folder in mutt. I spent couple hours to develop a workflow for doing this.
macro attach s "<shell-escape>~/.config/mutt/bin/saveattach.sh\n:source /tmp/from\ns" "Save attachment to specific folder" macro attach S "<shell-escape>~/.config/mutt/bin/saveattach.sh\n:source /tmp/from\ns" "Save attachment to specific folder"
- Shell script in
#!/bin/bash if [[ -e /tmp/from ]]; then rm /tmp/from fi echo $HOME"//" > /tmp/from nvim "+normal G$" +startinsert /tmp/from path=`cat /tmp/from` echo $path if [[ !(-d $path) ]]; then mkdir -p $path fi echo 'macro attach s "<save-entry><bol>'$path'\n"' > /tmp/from
How to Use
- in mutt, goto attachment page, save attach by type
nvimwill show up with file of
- Finish the path in
nvim, I use nvim here is because of the path auto completetion feature.
- Exit nvim, the select attachment will be save to the specified path automatically, and will go to the next attachment item;
sagain for saving the following attachments.