chiark / gitweb /
xterm-wrapper: Remove. xterm-title is more convenient and portable to other
[bin.git] / get-sig
1 #! /bin/bash
2
3 if [ "X$1" == "X" ]; then
4   NAME=$(grep '^\*' ~/.siglist | head -1 | tr -s '\t' ' ' | cut -d' ' -f2)
5   if [ -z "$NAME" ]; then
6     echo "Usage: $0 signature-group [pattern]" >&2
7     exit 1
8   fi
9 else
10   NAME=$1
11 fi
12
13 ARGS=$(grep "^$NAME\\>" ~/.siglist | head -1 | tr -s '\t' ' ' | cut -d' ' -f2-)
14 if [ -z "$ARGS" ]; then
15     echo "No such signature group: $NAME" >&2
16     exit 1
17 fi
18
19 BASEDIR=$(eval echo $(echo "$ARGS" | cut -d' ' -f1))
20 STATICFILE=$(eval echo $(echo "$ARGS" | cut -d' ' -f2))
21 FORTUNEARGS=$(eval echo $(echo "$ARGS" | cut -d' ' -f3-))
22
23 cd "$HOME/$BASEDIR"
24 cat "$STATICFILE"
25 if [ "$2" ]; then fortune $FORTUNEARGS -m "$2"; else fortune $FORTUNEARGS; fi