> % Right now I've achieved this functionality through a wrapper shell
> % script that greps for the alias name and invokes mutt with the real
> % user name.
> 
> That makes sense, though it sounds somewhat painful.

It is not really painful, or slow for that matter on my machine ...
Here is my quick and dirty script:

#!/bin/bash
#
# Wrapper script for automatically expanding mutt aliases
#
# Known issues: if an alias conflicts with a real folder name then
#               the alias wins!

ALIAS_FILE=$HOME/.mutt/mail_aliases

MUTT=/usr/bin/mutt

COMMAND=""

for ARG in $*; do
  if [ -n "`echo $ARG | grep '^='`" ]; then
    FOLDER=`echo $ARG | sed 's/=//'`
    LINE=`grep "^alias *$FOLDER " $ALIAS_FILE`
    if [ -n "$LINE" ]; then
      FOLDER=`echo $LINE | awk -F'<' '{print $2}' | awk -F'@' '{print $1}'`
      ARG="="$FOLDER
    fi
  fi

  if [ -n "$COMMAND" ]; then
    COMMAND=$COMMAND" "$ARG
  else
    COMMAND=$ARG
  fi
done

exec $MUTT $COMMAND


> Have you checked out Hans Bogaard's save_alias patch?  That lets you
> save your mail to foolong in =foo instead of =foolong, which is perhaps
> a backwards way of achieving what you want but adds the advantage that
> your aliases are less likely to collide than real world names and so you
> shouldn't have any (or should at least have fewer) problems in $folder :-)

Actually, I like this idea better than mine. I'll try this patch out.

Thanks,

Alexander

Reply via email to