use a variable in .muttrc
Hello, in order to organize outbox I wrote this script: (year.sh) - #!/bin/bash year=`date +%Y` if [ ! -d ~/Mail/OUTBOX/$year ] then mkdir ~/Mail/OUTBOX/$year echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' else echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' fi - and in .muttrc I wrote: source '~/bin/year.sh |' but it is as if $year did not exist. but if I write the script year.sh like this: - #!/bin/bash an=`date +%Y` if [ ! -d ~/Mail/OUTBOX/$an ] then mkdir ~/Mail/OUTBOX/$an echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' else echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' fi - it works fine. Why it does not work with $an ? How to use a variable with mutt ? -- Gérard signature.asc Description: Digital signature
Re: use a variable in .muttrc
On Thu, Sep 15, 2011 at 09:49:14AM +0200, Gérard Robin wrote: > Hello, > in order to organize outbox I wrote this script: (year.sh) > > - > #!/bin/bash > > year=`date +%Y` > > if [ ! -d ~/Mail/OUTBOX/$year ] > then > mkdir ~/Mail/OUTBOX/$year > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' > else > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' > > fi > - The use of '' to enclose the string means bash won't expand any variables inside. Try "" instead. > and in .muttrc I wrote: > > source '~/bin/year.sh |' > > but it is as if $year did not exist. > but if I write the script year.sh like this: > > - > #!/bin/bash > > an=`date +%Y` > > if [ ! -d ~/Mail/OUTBOX/$an ] > then > mkdir ~/Mail/OUTBOX/$an > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' > else > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' > > fi > - > > it works fine. > > Why it does not work with $an ? Red herring. You're not trying to use $an inside '' in this version. `` still works inside ''. > How to use a variable with mutt ? Hope this helps. -- - Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/ Finger athan(at)fysh.org for PGP key "And it's me who is my enemy. Me who beats me up. Me who makes the monsters. Me who strips my confidence." Paula Cole - ME signature.asc Description: Digital signature
Re: use a variable in .muttrc
Gérard Robin writes: > Hello, > in order to organize outbox I wrote this script: (year.sh) > > - > #!/bin/bash > > year=`date +%Y` > > if [ ! -d ~/Mail/OUTBOX/$year ] > then > mkdir ~/Mail/OUTBOX/$year > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' ~~~ I think this variable won't get expanded --- it's inside single quotes. Try using double quotes instead. > else > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' > > fi > - > > and in .muttrc I wrote: > > source '~/bin/year.sh |' > > but it is as if $year did not exist. > but if I write the script year.sh like this: > > - > #!/bin/bash > > an=`date +%Y` > > if [ ! -d ~/Mail/OUTBOX/$an ] > then > mkdir ~/Mail/OUTBOX/$an > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' > else > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' > > fi > - > > it works fine. > > Why it does not work with $an ? Explained above. > How to use a variable with mutt ? Mutt can read environments, but environment variables are inherited from the parent process --- probably the shell that you started it. But this way, the definition of $year and $an are in a shell forked by mutt, so the shell can't change the environment variables of their parent process. Hope it helps :) -- Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591 pgpEXm3FDa2y2.pgp Description: PGP signature
Re: use a variable in .muttrc
On 15Sep2011 10:41, Athanasius wrote: | On Thu, Sep 15, 2011 at 09:49:14AM +0200, Gérard Robin wrote: | > in order to organize outbox I wrote this script: (year.sh) | > - | > #!/bin/bash | > year=`date +%Y` | > if [ ! -d ~/Mail/OUTBOX/$year ] | > then | > mkdir ~/Mail/OUTBOX/$year | > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' | > else | > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' | > | > fi | > - | | The use of '' to enclose the string means bash won't expand any | variables inside. Try "" instead. Yes. But... | > but if I write the script year.sh like this: [...] | > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' | > else | > echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' | > | > fi | > - | > | > it works fine. | > | > Why it does not work with $an ? | | Red herring. You're not trying to use $an inside '' in this version. | `` still works inside ''. No. What is actually happening is that in _both_ cases the single quotes in his script are preventing $year _and_ the `command` stuff from happening. In his script! So what is being echoed for mutt to use is _literally_: set record==OUTBOX/$year/outbox-`date +%m-%y` or set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y` Now, in both these cases, mutt _will_ try to expand both $year and the `date...` parts. However, mutt hasn't got a $year to use. The `date...` stuff _does_ work. The second script works because mutt does not try to use $year. | > How to use a variable with mutt ? | Hope this helps. You've been misled by red herrings, alas. Gérard, use Athanasius' suggestion of double quotes in your script. You're not passing $year to mutt, but you will be passing the result you want. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The thought of suicide is a comforting one, for with it has come a calm passage through many a bad night. - Fred Nieztsche
Re: Mac Command Line and mutt
On 13Sep2011 03:43, Michael Graham wrote: | On Mon, Sep 12, 2011 at 17:07, Leo Vegoda wrote: | > […] In my experience it works the same on whichever OS you choose as long as you build in all the bits and pieces you need. | | That’s my experience too. I use it on my Mac, and also on a Linux VPS (which I’m using now), and I haven’t had any issues with either. The .muttrc is the same for both, and it works without problems the way I have it set up (YMMV). | | > For the latter issue, you might want to look at the different package management systems available for Mac OS, including Fink and MacPorts, to find out which versions they have available. | | I installed it on the Mac using Fink, and had no problems with it. If I recall correctly, the MacPorts copy was an older version. I'm using MacPorts. You need to install mutt-devel, not mutt: mutt @1.4.2.3 (mail) Mongrel of Mail User Agents (part Elm, Pine, Mush, mh, etc) mutt-devel @1.5.21 (mail) Mongrel of Mail User Agents (part Elm, Pine, Mush, mh, etc) so "mutt-devel" gets you the 1.5 series. Pretty up to date, too. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Programming: (n.) A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.- Dean Woodward
Re: Mac Command Line and mutt
On 13Sep2011 10:06, Tom Baker wrote: | I have a related problem since moving from XP to Mac last May. I save email | threads as MBOX files and reference them on the (local) home page of my | browser, Firefox. The home page is my to-do list, and it contains references | along the lines of: | | | | Under XP, with some fiddling, I was able configure Firefox to launch a batch file, | which launched a script, which launched "mutt -f important-email-exchange.mbox". Can you explain what you had to tell _firefox_ to achieve this? I'd imagine you need to associate .mbox file extensions with your script, and firefox's Prefs screens don't seem to offer me much control there. With a real web server instead of local file access one could tell the web server to offer the mbox file as a particular MIME type and go from there, but... | In | other words, one mouse click in my to-do list in Firefox put me right into mutt, | where I could read and directly respond to an email thread. I have been doing this | for years. Would the Finder do? Could you have the mboxen in a folder somewhere an open then from there? Bypassing Firefox. You can easily associate an app with a file extension; mine seems set up to hand mbox files to the Apple mail client at present. I can change that, but then the trick is to have an "app" that takes that and opens mutt in a Terminal window. | If I could solve this problem, then presumably I could configure the Mac to | open mutt when I click on a file such as "important-email-exchange.mbox" in | the Mac Finder. Indeed. There's a little shell script around called "appify" that wraps a shell script in the Mac app stuff for this, but I haven't got it working yet... Visit here: http://sixohthree.com/1314/shell-scripts-as-applications-in-mac-os-x http://git.abackstrom.com/appify.git Anyway, given that a open a Terminal and run mutt is very easy - some AppleScript via the oascript command to open Terminal, a shell script to fill in the strings. Personally I have a script called "+" that essentially runs: mutt -f "+$1" (with a lot of preamble guff). So I real my main inbox just by running this command: + and my "mutt and other mail things" folder thus: + mutt Do you not keep open terminals around? Is this easy enough? Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ They're not hiding, they're just selective. - overhead by WIRED at the Intelligent Printing conference Oct2006
Re: use a variable in .muttrc
On Thu, Sep 15, 2011 at 10:41:43AM +0100, Athanasius wrote: |Date: Thu, 15 Sep 2011 10:41:43 +0100 |From: Athanasius |To: Gérard Robin |Cc: mutt-users@mutt.org |Subject: Re: use a variable in .muttrc |User-Agent: Mutt/1.5.18 (2008-05-17) | |On Thu, Sep 15, 2011 at 09:49:14AM +0200, Gérard Robin wrote: -8< |> #!/bin/bash |> |> year=`date +%Y` |> |> if [ ! -d ~/Mail/OUTBOX/$year ] |> then |> mkdir ~/Mail/OUTBOX/$year |> echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' |> else |> echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' |> |> fi |> - | | The use of '' to enclose the string means bash won't expand any |variables inside. Try "" instead. sorry it's a rookie mistake on my part :( ---8<-- |> Why it does not work with $an ? | | Red herring. You're not trying to use $an inside '' in this version. |`` still works inside ''. | |> How to use a variable with mutt ? | | Hope this helps. yes it helped me and I also learn new words: red herring :) Thank you to everyone who replied to me -- Gérard
Re: Mac Command Line and mutt
On Thu, Sep 15, 2011 at 10:58:08PM +1000, Cameron Simpson wrote: > | I have a related problem since moving from XP to Mac last May. I save email > | threads as MBOX files and reference them on the (local) home page of my > | browser, Firefox. The home page is my to-do list, and it contains > references > | along the lines of: > | > | > | > | Under XP, with some fiddling, I was able configure Firefox to launch a > batch file, > | which launched a script, which launched "mutt -f > important-email-exchange.mbox". > > Can you explain what you had to tell _firefox_ to achieve this? Under Windows XP, I had to associate the MBOX file format with a batch file (.BAT), so that it would run the batch file whenever I clicked on a reference to an MBOX file. Many years ago, I could add a MIME Type by hand into an RDF configuration file for Firefox. In subsequent versions it became more difficult to add MIME types. In the end, if I recall, I could add a MIME Type by clicking on a reference with an unknown extension (.mbox) and filling in the "open with" details. > I'd imagine you need to associate .mbox file extensions with your > script, and firefox's Prefs screens don't seem to offer me much control > there. With a real web server instead of local file access one could > tell the web server to offer the mbox file as a particular MIME type and > go from there, but... > > | In > | other words, one mouse click in my to-do list in Firefox put me right into > mutt, > | where I could read and directly respond to an email thread. I have been > doing this > | for years. > > Would the Finder do? Could you have the mboxen in a folder somewhere an > open then from there? Bypassing Firefox. If I were able to do that in Finder -- open an mbox file by clicking on it -- then I should think I'd be able to call the same program or script from Firefox, but I haven't been able to do either one. I can already by-pass Firefox by opening the file in the Terminal with "mutt -f". For me, opening the mboxen in Firefox is important because they are embedded in my TODO list, which is my Firefox home page. I am continually editing my todo list and updating the Web page using a script I wrote in eighteen years ago (see lifehacker.com article http://tinyurl.com/y4upo4), recently rewritten in Python for speed and portability (see http://code.google.com/p/shawkle/). > You can easily associate an app with a file extension; mine seems set up > to hand mbox files to the Apple mail client at present. I can change > that, but then the trick is to have an "app" that takes that and opens > mutt in a Terminal window. Right - I figured this should be possible. Would one do that with Automator or Applescript? I tried the former, with no success, and am reluctant to get further into the latter without knowing that this approach could in principle work. > | If I could solve this problem, then presumably I could configure the Mac to > | open mutt when I click on a file such as "important-email-exchange.mbox" in > | the Mac Finder. > > Indeed. > > There's a little shell script around called "appify" that wraps a shell > script in the Mac app stuff for this, but I haven't got it working > yet... Visit here: > > http://sixohthree.com/1314/shell-scripts-as-applications-in-mac-os-x > http://git.abackstrom.com/appify.git > > Anyway, given that a open a Terminal and run mutt is very easy - some > AppleScript via the oascript command to open Terminal, a shell script to > fill in the strings. > > Personally I have a script called "+" that essentially runs: > > mutt -f "+$1" > > (with a lot of preamble guff). So I real my main inbox just by running > this command: > > + Very cool - thanks for the tip! > and my "mutt and other mail things" folder thus: > > + mutt > > Do you not keep open terminals around? Is this easy enough? I always have alot of open terminals, but when I see a link in my browser, I have to copy-and-paste the reference to my mutt -f terminal command. Doable, but it really slows me down when I'm working through email threads... Thank you very much for the "applify" links. Will let you know if I'm able to get this to work...! Tom -- Tom Baker
Re: use a variable in .muttrc
On Thu, Sep 15, 2011 at 09:49:14AM +0200, Gérard Robin wrote: > Hello, > in order to organize outbox I wrote this script: (year.sh) > > - > #!/bin/bash > > year=`date +%Y` > > if [ ! -d ~/Mail/OUTBOX/$year ] > then > mkdir ~/Mail/OUTBOX/$year > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' > else > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' > > fi As an aside, in addition to the responses you've had to your query, you have a redundant use of else in your script. It would work just as well written as #!/bin/bash year=`date +%Y` if [ ! -d ~/Mail/OUTBOX/$year ]; then mkdir ~/Mail/OUTBOX/$year fi echo "set record==OUTBOX/$year/outbox-`date +%m-%y`" Cheers, Tom -- The first thing I do in the morning is brush my teeth and sharpen my tongue. -- Dorothy Parker signature.asc Description: Digital signature