Parametrize shell escape command

Kevin J. McCarthy kevin at 8t8.us
Tue Dec 31 01:54:06 UTC 2024


On Mon, Dec 30, 2024 at 11:38:45AM -0800, googly.negotiator862 at aceecat.org wrote:
>for my next mutt tweak, my goal is to set up a macro key binding which 
>will go in the pager keymap and, as its main job, will execute a 
><shell-escape>. The part which -- as far as I can see -- is nontrivial: 
>I need to pass the name of the current folder as an argument to the 
>executed script.
>
>It is easy enough to set up a series of folder-hook mutt config 
>commands so that the name ends up in a user mutt variable, say 
>$my_folder_name. The seeming difficulty is in exporting this value to 
>the external environment (in the precise Unix sense of this term). So 
>far, any way I've thought of doing this turned out to only "beg the 
>question".

The safest way might be to just use an environment variable instead. 
Then, you can deal with parameter quoting issues properly in your 
script, in a way that Mutt can't.

However, if it has to be a parameter, and you're not concerned about 
parameter quoting, you could try redefining the macro in a folder hook 
too, after the mutt user variable is regenerated:

folder-hook . 'set my_folder=$folder;set folder="XXX";set visual=^'
folder-hook . 'set my_mailbox=$visual;setenv MYMAILBOX $visual'
folder-hook . 'set folder=$my_folder'
folder-hook . 'macro index ,q "<shell-escape>echo $my_mailbox > /tmp/foo<enter>"'

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.mutt.org/pipermail/mutt-users/attachments/20241231/5708fe06/attachment.sig>


More information about the Mutt-users mailing list