Mutt:使用 offlineimap 仅下载当前文件夹

Mutt: download only current folder using offlineimap

背景: 我用offlineimap下载邮件,用侧边栏切换文件夹显示。以前,我硬编码为仅同步 "INBOX" 文件夹。这是我的 .muttrc 相关的一部分:

macro index o "<sync-mailbox>.<shell-escape>offlineimap -qf INBOX<enter>.<sync-mailbox>" "run offlineimap to sync inbox"

目标: 我想同步当前打开的文件夹。本质上,我想 获取一个包含当前打开文件夹名称的变量 ,并将硬编码的 "INBOX" 替换为该名称。但是,我没有找到如何获取当前打开的文件夹。而且 "folder-hook" 方法似乎不起作用。

作为解决方法,使用文件夹挂钩,在进入 $folder 时重新绑定绑定以仅更新 $folder。例如

folder-hook .               'macro index o "<shell-escape>offlineimap -qo >/dev/null 2>&1 &<enter><sync-mailbox><refresh>"'
folder-hook =INBOX$         'macro index o "<shell-escape>offlineimap -qo -f INBOX >/dev/null 2>&1 &<enter><sync-mailbox><refresh>"'
folder-hook =INBOX.Sent$    'macro index o "<shell-escape>offlineimap -qo -f INBOX.Sent >/dev/null 2>&1 &<enter><sync-mailbox><refresh>"'