#!/bin/ksh # # $Id: rem,v 1.5 2006/07/28 21:16:11 vogelke Exp $ # # NAME: # rem # # SYNOPSIS: # rem [-hv] [file] # # DESCRIPTION: # Edits the agenda file in your notebook directory (default), # or one entered on the command line. # # OPTIONS: # -h, --help print help information and exit # -v, --version print the version and exit # # AUTHOR: # Based on Free Software Foundation configure scripts. # Karl Vogel # Sumaria Systems, Inc. # # HISTORY # Message-ID: <914f813c0607281329l2f9316e4m43491aec243145cf@mail.gmail.com> # Date: Fri, 28 Jul 2006 15:29:08 -0500 # From: "John T. Hoffoss" # To: vogelke+43folders@pobox.com # Subject: Organizing my stuff -- rem shell script # # I modified the rem shell script to work with a few parameters. # Much of my task planning occurs for the next few days in the # future, so the auomatically created symlinks for the next week # come in very handy. # # Rather than specify the days in a full path though, I added a # few parameters for the rem script to accept, and set the day # accordingly. PATH=/bin:/usr/bin:/usr/local/bin : ${EDITOR="/usr/bin/vi"} export PATH EDITOR umask 022 tag=`basename $0` # ============================= FUNCTIONS ================================== die () { echo "$tag: ERROR -- $*" >& 2 exit 1 } # usage: prints an optional string plus part of the comment # header (if any) to stderr, and exits with code 1. usage () { lines=`egrep -n '^# (NAME|AUTHOR)' $0 | sed -e 's/:.*//'` ( case "$#" in 0) ;; *) echo "usage error: $*"; echo ;; esac case "$lines" in "") ;; *) set `echo $lines | sed -e 's/ /,/'` sed -n ${1}p $0 | sed -e 's/^#//g' | egrep -v AUTHOR: ;; esac ) 1>&2 exit 1 } version () { local_sedscr='s/RCSfile: // s/.Date: // s/,v . .Revision: / v/ s/\$//g' local_revno='$RCSfile: rem,v $ $Revision: 1.5 $' local_revdate='$Date: 2006/07/28 21:16:11 $' echo "$local_revno $local_revdate" | sed -e "$local_sedscr" } # ======================== MAIN PROGRAM ========================== ac_invalid="invalid option; use -h or --help to show usage" afile=$HOME/today/agenda for ac_option do # main switch case "$ac_option" in -h | -help | --help | --hel | --he) usage ;; -v | -version | --version | --versio | --versi | --vers) version; exit 0 ;; -*) die "$ac_option: $ac_invalid" ;; t) die "Please specify -to, -tu, or -th" ;; s) die "Please specify -sa or -su" ;; y*) afile=$HOME/yesterday/agenda ;; to*) afile=$HOME/tomorrow/agenda ;; m*) afile=$HOME/monday/agenda ;; tu*) afile=$HOME/tuesday/agenda ;; w*) afile=$HOME/wednesday/agenda ;; th*) afile=$HOME/thursday/agenda ;; f*) afile=$HOME/friday/agenda ;; sa*) afile=$HOME/saturday/agenda ;; su*) afile=$HOME/sunday/agenda ;; *) afile="$ac_option" ;; esac done # # Real work starts here. # test -e "$afile" || echo "REM MSG new agenda" > $afile exec $EDITOR $afile exit 0