Miguel Farah F. [[EMAIL PROTECTED]] wrote:
> Also: one of the nice things about tin (the news reader) is that it
> lets you have a random signature (there's a fixed part and a random
> one, selected from the files in a directory previously declared). It'd
> be nice it mutt could do that as well.
> 

Mutt can do this with a little help =)

Here is a perl script that will do what you want:


#!/usr/bin/perl
# randsig.pl, by Don Blaheta.  Released into public domain, blah, blah, blah.
# Generates a signature randomly from a single file of witty quotes which
# the user maintains; the quotes can be multi-line, and are separated by
# blank lines. 

# Modifications by Glenn Maynard:
# Put your own signature in a file (typically ~/.sig), and your quotes in
# another file (ie ~/.randsig).  Put "%QUOTE%" in your signature file where
# you want a quote replaced. To simply output your sig with no quote 
# (%QUOTE removed), don't specify a quotefile.

# Cleaned up by me =)
# Place something like the following in your .muttrc to use this script.
# set signature="~/bin/randsig3.pl .sig ~/.mutt/quotes|"

$home =  $ENV{"HOME"}; 

if ($#ARGV lt 0 or $#ARGV gt 1) {
  print "Usage: $^X sigfile [quotefile]\n";
  exit 1;
} 

# determine the quote 
if ($#ARGV eq 1) {
  open (FI, "$ARGV[1]") or die "Can't open $ARGV[1]"; 

  # count the quotes
  $sig[0] = 0;
  while (<FI>) { $sig[$#sig + 1] = tell if /^$/; } 

  # read one
  srand;
  seek(FI, $sig[int rand ($#sig + .9999)], SEEK_SET) or die "Can't seek";
  while (<FI>) {
    last if /^$/;
    chomp ($_);
    $msg .= "\n";
    $msg .= $_;
  }
} 

open (SIG, "$ARGV[0]") or die "Can't open $ARGV[0]";
while (<SIG>) {
  $_ =~ s/%QUOTE%/$msg/;
  print "$_";
} 

-- 
Robert Berkowitz

"We stand together tonight not as Democrats or Republicans but as citizens
of the world, as Americans, as brothers and sisters with pain and with 
hurt. We are a circle of trust that cannot be broken. We are one people. 
We are one family. We are one nation."
- Rep. John Lewis, D-Georgia

PGP signature

Reply via email to