Re: use current folder name as argument to abitrary command
On Fri, Dec 12, 2008 at 10:59:12AM -0600, Kyle Wheeler wrote:
> IF you could get $my_curdir to work, you could get your wish by
> constantly re-creating the macro. But that gives me an idea - here's
> something that should work:
>
> folder-hook . "set my_oldrecord=\$record"
> folder-hook . "set record=^"
> folder-hook . \
> macro index,pager "<save-message>$my_archdir/$record<enter>"
> folder-hook . "set record=\$my_oldrecord"
>
> This way, we can use the "special" status of $record to force the ^ to
> be expanded. First, we save the contents of $record into a temporary
> variable (so we need to escape $record). Then we set $record to ^.
> Then we rebind the macro so that it's got the correct contents (note
> we don't want escaping here). Then we restore $record's original
> value.
Thanks! This does what I need: gets the name of the current folder in a
variable without messing up $record, and makes my macro work on whatever
the current folder path is. I modified it slightly so that I get the
current folder path in a variable on its own so I can be free to play
with it further:
folder-hook . "set my_oldrecord=\$record"
folder-hook . "set record=^"
folder-hook . "set my_curdir=\$record"
folder-hook . "set record=\$my_oldrecord"
The next step is to strip down that name so I have only the folder name,
not the full path. The best way I can think to do this would be to pass
the full path folder variable to a shell command which will strip that
down, and return the folder name to another variable (or the same one, I
don't care). I'm stuck at figuring out how to pass a mutt variable to a
shell command.
For testing, my command is:
folder-hook . "set my_testval=`echo \$my_curdir`"
Now it gets weird. That very simple command works. set ?my_testval
returns the full path to the folder. But, if I make some simple
addition, for example:
folder-hook . "set my_testval=`echo \$my_curdir | rev`"
then rather than getting the full path to the mail folder, reversed, I
get
ridruc_ym$
which is of course "$my_curdir" in reverse. Why does the addition of one
simple pipe command make mutt stop interpreting the variable?
Thanks,
--
Noah Sheppard
Assistant Computer Resource Manager
Taylor University CSE Department
nsheppar@xxxxxxxxxxxxxx