Re: Add alias during session
* On 2007.02.05, in <20070206034833.GM23569@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
* "cricketc@xxxxxxxxx" <cricketc@xxxxxxxxx> wrote:
>
> Is there really no way to do a generic create-alias, where you don't
> have to change the information of the current sender? I've often
> wanted to do this - just hit 'a', but not have to erase all the
> information I don't want first (I just want it blank so I can enter
> what I want).
macro index A "<enter-command>source '~/bin/mutt-add-alias |'<enter>"
mutt-add-alias is attached.
--
-D. dgc@xxxxxxxxxxxx NSIT University of Chicago
#!/bin/sh
ALIAS_FILE=${MUTT_ALIASES:-$HOME/.mutt/aliases}
q='"'
exec 9>&1
exec </dev/tty >/dev/tty 2>&1
get_vals () {
printf "New alias name${alias:+ [$alias]}: "
read line
alias=${line:-$alias}
printf "Enter e-mail address${addr:+ [$addr]}: "
read line
addr=${line:-$addr}
printf "Enter comment/name${name:+ [$name]}: "
read line
name=${line:-$name}
new=`echo $name | tr -d '"'`
if [ ! "$new" = "$name" ]; then
printf "(Removing double-quotes from $q$name$q.)\n"
name="$new"
fi
}
notfinished=true
while $notfinished; do
printf "\n"
get_vals
printf "\n"
notfinished=
while [ "$notfinished" = "" ]; do
printf "Is this correct: $alias = $name <$addr> [yes]? "
read line
case "$line" in
""|y*|j*|s*|o*) notfinished=false ;;
n*) notfinished=true ;;
*) echo "Yes or no is good." ;;
esac
done
done
printf "alias %-16s %s <%s>\n" "$alias" "$q$name$q" "$addr" >>"$ALIAS_FILE"
printf "\nAdded alias $q$alias$q for $q$name$q <$addr>\n\n"
cat "$ALIAS_FILE" >&9