On Fri, Feb 18, 2011 at 05:13:55PM -0500, Paul Hoffman wrote:
Then /path/to/my/script has something along these lines:

#!/bin/zsh

typeset file=$1 label subject; shift
typeset editor=${VISUAL:-$EDITOR}

main() {
   grep '^Subject: ' $file | read label subject
   if [[ -n $subject ]]; then
       newfile=$(sanitize-subject $subject)
       ln -f $file $file:h/$newfile
   fi
   exec ${editor:-vi} $file

Since $editor doesn't know anything about $newfile, it gets left around afterward.

I think he would want to replace the editor line above with:

    ${editor:-vi} $file
    rm $newfile

Alternately, he might just want a script that will allow him to more easily identify the leftover tempfiles. No changes to muttrc needed for this:

#!/usr/bin/perl -w

#
# Name: listMuttTemp
# By: Ed Blackman <e...@edgewood.to>
# Invocation: listMuttTemp /path/to/mutt-tempfiles/mutt-*
#

use POSIX;

foreach my $file (@ARGV) {
  if(open(my $fh, '<', $file)) {
    while(<$fh>) {
      if(/^Subject: /) {
        my @modificationTime = localtime((stat($file))[9]);

        print "$file:\n$_" . strftime("%x %X", @modificationTime) . "\n\n";
      }
    }

    close($fh);
  }
  else {
    print STDERR "Couldn't read $file: $!\n";
  }
}

That produces:
$ listMuttTemp /tmp/mutt-*
/tmp/mutt-loghyr-1237-5892-3031e76d5f93d2eeb87:
Subject: Re: renaming temporary files
02/18/2011 05:27:35 PM

--
Ed Blackman

Attachment: signature.txt
Description: Digital signature

Reply via email to