Re: Working with mbox
Rob 'Feztaa' Park wrote: Alas! Benjamin Smith spake thus: The ways that script works is by outputting the muttrc to a tempory file, the name of which is outputted for source, but what you can do is just to put: `~/bin/do-whatever.sh` In the muttrc and mutt will interpret the output of the shell script without the need of tempory files. Nope, that was the first thing I tried, didn't work. source $HOME/bin/mutt-prep folders=$HOME/mail| (note the | at the end of the command) should work without a temporary file. Regards... Michael
Re: Working with mbox
Alas! David T-G spake thus: % The .muttrc is fairly robust. You can put almost any shell command into % backticks (``), and it will be as though the output of that command is % actually in the .muttrc file. This is why mutt is so much better than % pine :) Um, yeah; that's the *only* reason. Sre... *grin* Well, sure there are a few hundred more, but that's one of the big ones (for me, anyway). I love scripting stuff into my .muttrc :) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- The depressing thing about tennis is that no matter how good I get, I'll never be as good as a wall. -- Mitch Hedberg msg22371/pgp0.pgp Description: PGP signature
Re: Working with mbox
On Sun, Jan 06, 2002 at 01:30:35AM -0700, Rob 'Feztaa' Park wrote: Alas! Benjamin Smith spake thus: The ways that script works is by outputting the muttrc to a tempory file, the name of which is outputted for source, but what you can do is just to put: `~/bin/do-whatever.sh` In the muttrc and mutt will interpret the output of the shell script without the need of tempory files. Nope, that was the first thing I tried, didn't work. I had to modify the script to output the mbox hooks to a temp file, and then output the tempfile's name to stdout, which could then be sourced in the .muttrc. Strange, I seemed to work fine with me when I tried `echo push ?` so that mutt would always popup the help screen. -- Benjamin Smith [EMAIL PROTECTED], [EMAIL PROTECTED] msg22377/pgp0.pgp Description: PGP signature
Re: Working with mbox
Alas! Gerhard Siegesmund spake thus: You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` Thanks for your help, guys, this is what I've come up with: my .muttrc contains this line: source `~/bin/mbox-hooks` This has been a great discussion. I didn't know mutt could source the output of a command. Which version of mutt does this? I am using 1.2.5.1i and I just get an error trying to source the output of a command. TIA I'm fairly sure that mutt will only source the output of a command if the output of a command is a filename for mutt to source :) The .muttrc is fairly robust. You can put almost any shell command into backticks (``), and it will be as though the output of that command is actually in the .muttrc file. This is why mutt is so much better than pine :) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- The perfect computer has been developed. You just feed in your problems and they never come out again. -- Al Goodman msg22333/pgp0.pgp Description: PGP signature
Re: Working with mbox
On Sat, Jan 05, 2002 at 10:11:10AM -0700, Rob 'Feztaa' Park wrote: Alas! Gerhard Siegesmund spake thus: You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` Thanks for your help, guys, this is what I've come up with: my .muttrc contains this line: source `~/bin/mbox-hooks` This has been a great discussion. I didn't know mutt could source the output of a command. Which version of mutt does this? I am using 1.2.5.1i and I just get an error trying to source the output of a command. TIA I'm fairly sure that mutt will only source the output of a command if the output of a command is a filename for mutt to source :) The .muttrc is fairly robust. You can put almost any shell command into backticks (``), and it will be as though the output of that command is actually in the .muttrc file. This is why mutt is so much better than pine :) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- The perfect computer has been developed. You just feed in your problems and they never come out again. -- Al Goodman The ways that script works is by outputting the muttrc to a tempory file, the name of which is outputted for source, but what you can do is just to put: `~/bin/do-whatever.sh` In the muttrc and mutt will interpret the output of the shell script without the need of tempory files. -- Benjamin Smith [EMAIL PROTECTED], [EMAIL PROTECTED] msg22342/pgp0.pgp Description: PGP signature
Re: Working with mbox
Rob -- ...and then Feztaa said... % ... % The .muttrc is fairly robust. You can put almost any shell command into % backticks (``), and it will be as though the output of that command is % actually in the .muttrc file. This is why mutt is so much better than % pine :) Um, yeah; that's the *only* reason. Sre... *grin* % % -- % Rob 'Feztaa' Park % [EMAIL PROTECTED] % -- % The perfect computer has been developed. You just feed in your % problems and they never come out again. % -- Al Goodman Happy New Year to all! :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg22354/pgp0.pgp Description: PGP signature
Re: Working with mbox
On Tue, Jan 01, 2002 at 11:07:08PM -0700, Rob 'Feztaa' Park [EMAIL PROTECTED] wrote: | Hey all. I was just wondering if there was some way that I could get | mutt to automatically set up my mbox hooks for every folder in my ~/mail | directory, so that way I can subscribe to a new mailing list without | having to edit my .muttrc. | | Right now I've got this set up: | | mbox-hook =spam =archives/`date +%Y-%m`-spam | mbox-hook =inbox =archives/`date +%Y-%m`-inbox | ... | | (and so on for all of my mboxes). I want to automate this so I don't | have to write a new one for all future mailing lists that I might decide | to subscribe to :) | | I'm pretty sure I've seen this done somewhere, but I can't find it. Well, it's indirect, but you could wrap mutt in a script which said: #!/bin/sh ( cd $HOME/mail when=`date +%Y-%m` for mbox in * do echo mbox-hook =$mbox \=archives/$when-$mbox\ done $HOME/.muttrc-auto ) exec real-mutt-program ${1+$@} and just source .muttrc-auto from .muttrc. Ugly but would work. -- Cameron Simpson, DoD#743[EMAIL PROTECTED]http://www.zip.com.au/~cs/ Will hack Perl code in spite of what my boss might say. - Dave Rensin, [EMAIL PROTECTED]
Re: Working with mbox
Alas! Cameron Simpson spake thus: | I'm pretty sure I've seen this done somewhere, but I can't find it. Well, it's indirect, but you could wrap mutt in a script which said: #!/bin/sh ( cd $HOME/mail when=`date +%Y-%m` for mbox in * do echo mbox-hook =$mbox \=archives/$when-$mbox\ done $HOME/.muttrc-auto ) exec real-mutt-program ${1+$@} and just source .muttrc-auto from .muttrc. Ugly but would work. Interesting idea. I'm sure I've seen a better way to do it, though. Perhaps I'll have to search the archives :) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- Logic doesn't apply to the real world. -- Marvin Minsky msg22257/pgp0.pgp Description: PGP signature
Re: Working with mbox
On 2002.01.04, in [EMAIL PROTECTED], Rob 'Feztaa' Park [EMAIL PROTECTED] wrote: Alas! Cameron Simpson spake thus: | I'm pretty sure I've seen this done somewhere, but I can't find it. Well, it's indirect, but you could wrap mutt in a script which said: #!/bin/sh ( cd $HOME/mail when=`date +%Y-%m` for mbox in * do echo mbox-hook =$mbox \=archives/$when-$mbox\ done $HOME/.muttrc-auto ) exec real-mutt-program ${1+$@} and just source .muttrc-auto from .muttrc. Ugly but would work. Interesting idea. I'm sure I've seen a better way to do it, though. Perhaps I'll have to search the archives :) I'm into overkill today. You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` This approach lets your mutt-prep script write anything muttrc-ish on its stdout, and mutt will absorb it with no shell wrappers. The cmdline eval lets your source line configure the script's parameters easily. (You could do it with prefixed variables or /bin/env, but this makes them local instead of environmental, fwiw, and it might be easier to read.) It's fundamentally the same idea, but you don't have to mess with wrappers, at least. It feels a little neater, in some way I can't explain. -- -D.[EMAIL PROTECTED]NSITUniversity of Chicago #!/bin/sh ## ## This emits muttrc commands on stdout. call it with ## source `/path/to/mutt-prep` ## in your .muttrc file. ## ## Set variables from cmdline. eval $@ ## Set defaults -- these can be overridden on the cmdline. file=${file-$HOME/.mutt-runtime} folders=${folders-$HOME/Mail} ## All output goes to $file. echo the filename first, so mutt can source it. echo $file exec $file ## Set mbox-hooks. when=`date +%Y-%m` (cd $folders ls | sed -e 's#\(.*\)#mbox-hook =\1 =archives/\1-'$when'#' ) ## Set mailboxes (could be merged above). (cd $folders ls | sed -e 's#\(.*\)#mailboxes =\1#' ) ## Something to source an rc file if present. try_source () { for rc in $@; do if [ -f $HOME/.mutt-$rc ]; then echo source $HOME/.mutt-$rc fi done } ## Source an NNTP config file if mutt has NNTP support. if mutt -v | grep NNTP /dev/null; then try_source nntp fi ## Source a muttrc for this host or domain, if one exists. try_source `hostname` `sed -e '1s/.* //;q' /etc/resolv.conf` ## Dynamically convert my pine addressbook to mutt format. if [ -f $HOME/.addressbook ]; then cat $HOME/.addressbook \ | awk '-F ' '/^[^ ]/{printf(alias %-20.20s %s %s\n, $1, $2, $3);}' #^^^ that's a tab character fi ## Add other runtime tasks as you like.
Re: Working with mbox
Alas! David Champion spake thus: and just source .muttrc-auto from .muttrc. Ugly but would work. Interesting idea. I'm sure I've seen a better way to do it, though. Perhaps I'll have to search the archives :) I'm into overkill today. You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` This approach lets your mutt-prep script write anything muttrc-ish on its stdout, and mutt will absorb it with no shell wrappers. The cmdline eval lets your source line configure the script's parameters easily. (You could do it with prefixed variables or /bin/env, but this makes them local instead of environmental, fwiw, and it might be easier to read.) It's fundamentally the same idea, but you don't have to mess with wrappers, at least. It feels a little neater, in some way I can't explain. Well, I had a bit of a hard time following your script, but based on the pine addressbook bit, I take it it doesn't do _quite_ what I'm looking for... but it gave me an idea (not sure if this is what you were already doing...): Would it be possible to write a script that simply writes muttrc stuff to a file, and the writes the filename to stdout? That way I'd still be avoiding the wrapper. I'm going to try that, I'll let you know the results :) ## This emits muttrc commands on stdout. call it with ##source `/path/to/mutt-prep` ## in your .muttrc file. Now I'm just confused... so you're saying that the end result would be this: source mbox-hook =folder =archives/`date +%Y-%m`-folder ?? Can source take muttrc commands? I thought source only took filenames. -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- It takes 5 NT servers to offer the performance and availability of a single UNIX server. -- Network Computing, July 15 1998 msg22296/pgp0.pgp Description: PGP signature
Re: Working with mbox
Alas! Rob 'Feztaa' Park spake thus: I'm into overkill today. You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` Thanks for your help, guys, this is what I've come up with: my .muttrc contains this line: source `~/bin/mbox-hooks` and the script is attached. -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- The Irish gave the bagpipes to the Scots as a joke, but the Scots haven't seen the joke yet. -- Oliver Herford #!/bin/bash # Changing into the mail directory is less processor-intensive than # running basename on every file cd ~/mail/ # This is the name of the file to store our mbox hooks in file=/home/feztaa/.mutt/muttrc-mboxes # Prime the file: make sure it's there and overwrite whatever's in it echo # Mbox hooks for mutt! $file # For every mbox we have, echo the appropriate mbox-hooks into the file. for i in *; do [ -d $i ] || echo mbox-hook =$i \=archives/$(date +%Y-%m)-$i\ $file done # Echo the filename to stdout so that the source command in .muttrc picks it up. echo $file # Change back into the previous directory (this outputs text that we don't want) cd - /dev/null 21 msg22299/pgp0.pgp Description: PGP signature
Re: Working with mbox
Alas! Gary Johnson spake thus: cd - /dev/null 21 This is not necessary. The command within `s is executed as a child process of mutt. Unix child processes cannot affect the working directory of their parent. So, none of the cd'ing within the mbox-hooks command will have any effect on mutt's working directory. True, guess I wasn't thinking. It's not the first time I've had to have a script cd somewhere then cd back. Just habit now :) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- Microsoft - because God hates us. msg22301/pgp0.pgp Description: PGP signature
Re: Working with mbox
You could put that in a script such as the one I've attached, and run it from .muttrc like this: source `$HOME/bin/mutt-prep folders=$HOME/mail` Thanks for your help, guys, this is what I've come up with: my .muttrc contains this line: source `~/bin/mbox-hooks` This has been a great discussion. I didn't know mutt could source the output of a command. Which version of mutt does this? I am using 1.2.5.1i and I just get an error trying to source the output of a command. TIA -- cu --== Jerri ==-- Homepage: http://www.jerri.de/ ICQ: 54160208 msg22306/pgp0.pgp Description: PGP signature
Re: Working with mbox
Alas! David T-G spake thus: It's untested, but what about mbox-hook . =archives/`date +%Y-%m`-%O Sorry, doesn't work. It sees %O as the literal string, doesn't expand it into anything. -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- The wireless music box has no imaginable commercial value. Who would pay for a message sent to nobody in particular? -- David Sarnoff's associates in response to his urging for investment in the radio in the 1920s msg22185/pgp0.pgp Description: PGP signature
Re: Working with mbox
Rob -- ...and then Feztaa said... % % Hey all. I was just wondering if there was some way that I could get % mutt to automatically set up my mbox hooks for every folder in my ~/mail % directory, so that way I can subscribe to a new mailing list without % having to edit my .muttrc. % % Right now I've got this set up: % % mbox-hook =spam =archives/`date +%Y-%m`-spam % mbox-hook =inbox =archives/`date +%Y-%m`-inbox % ... It's untested, but what about mbox-hook . =archives/`date +%Y-%m`-%O to tell mutt to save in the original save folder but under this new directory? %O is detailed in 6.3.76, and I like to use it in conjunction with the %_ patch from O'Shaughnessy Evans to ensure that the folder name will be lowercased. % % (and so on for all of my mboxes). I want to automate this so I don't % have to write a new one for all future mailing lists that I might decide % to subscribe to :) % % I'm pretty sure I've seen this done somewhere, but I can't find it. % % Thanks :) HTH HAND Happy New Year to all! % % -- % Rob 'Feztaa' Park % [EMAIL PROTECTED] % -- % The Irish gave the bagpipes to the Scots as a joke, but the Scots % haven't seen the joke yet. % -- Oliver Herford :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg22099/pgp0.pgp Description: PGP signature