cboltz.de

Random signatures in mails

Random signatures are a nice way to make mails funnier and more diversified. But how does the random sig come below your mail?

The first step is collecting signatures. Creating an own collection is the way that provides most fun.

You can add sigs to your collection using the addsig command below. The script starts an editor (vi) for entering the new sig, creates the matching *.dat file (required by fortune) using strfile and commits the whole signature collection to CVS to avoid data loss.

BTW: ###cb### in the signature file is a comment which gets grepped away by makesig again. addsig automatically adds the date as comment, but you can add more comments if you want.

#!/bin/bash # addsig (c) Christian Boltz 2004-2019 / GPL # --noedit: only update *.dat, do not enter new signature # (useful after editing $SIGFILE manually) SIGDIR="${HOME}/sigs" TMPFILE="${SIGDIR}/addsig.tmp" # If you decide to use a temp file in /tmp, # using mktemp is highly recommended! SIGFILE="${SIGDIR}/gute_sigs" test "$1" '!=' "--noedit" && { echo >> "$TMPFILE" echo "###cb### `date +%Y-%m-%d`" >> $TMPFILE vi "$TMPFILE" echo "%" >> "$TMPFILE" cat "$TMPFILE" >> "$SIGFILE" && rm "$TMPFILE" || exit 1 } /usr/sbin/strfile -s "$SIGFILE" "${SIGFILE}.dat" && \ echo " sig added successfully." cd "${SIGDIR}" && cvs commit -m "autobackup"

 
When you have collected enough sigs (or use those delivered with fortune) you can have fun in your mails ;-)  Just tell your mail user agent to read the signature from the command output of the following makesig script. I recommend using the --mail parameter which can save you some typing.

#!/bin/bash # makesig (c) Christian Boltz 2004-2019 / GPL # --mail: output regards line also # --staticsig: static sig # --english: english regards line (please note that the original # script was written in German ;-) SIG="`/usr/bin/fortune \"${HOME}/sigs/gute_sigs\" | grep -v '^###cb###'`" gruss='Regards,' # gruss="Marry X-Mas" mail=0 name='script "stolen" from Christian Boltz - www.cboltz.de' staticsig='hardcoded sig when using --staticsig' # SIG='special text instead random signature (without --staticsig' while [ -n "$1" ] ; do case "$1" in --staticsig) SIG="$staticsig" ;; --english) gruss="Regards," ;; --mail) mail=1 ;; *) echo "*** unknown option $1 ***" exit 1 ;; esac shift done if [ "$mail" = 1 ] ; then echo "$gruss" echo echo "$name" echo "-- " fi echo "$SIG"

 
When you are searching a specifig signature from your collection, the grepsig script may be useful for you. You can either use agrep or fortune, but fortune is the better solution.

#!/bin/bash # grepsig (c) Christian Boltz 2004-2019 / GPL # agrep -d'^%$' -i "$@" "${HOME}/sigs/gute_sigs" /usr/bin/fortune "${HOME}/sigs/gute_sigs" -i -m "$1"

last update: 19.07.2005