oreilly.comSafari Books Online.Conferences.


Organizing Files
Pages: 1, 2, 3, 4, 5, 6, 7

Things That Started to Go Right

The most noticeable improvement was finally being able to find the things that happened on a given date.

Here's what convinced me that I was on the right track: I'd think of a problem, and a moment later a fix would occur to me that was consistent and doable. Most of the scripts and utilities I needed were either already available or took fewer than 20 minutes to write.

Where is today's stuff?

About 95 percent of the time, I'm dealing with stuff for yesterday, today, and the coming week. A few symbolic links made navigation pretty easy (Figure 4).

Symlinks for navigation
Figure 4. Symlinks for navigation

I can get to next Monday's folder by typing cd ~/monday at the prompt, no matter where I am in the filesystem. Because I use the Z shell, I can also get there by just typing monday. Here are the shell settings:

cdpath=(.. ~ )  # specify a search path for the cd command.
setopt autocd   # cd to a directory if it's the first word on the command line.

How to do scheduling

Remind is a calendar and reminder program for Linux and most Unix systems, and it's made to order for this sort of thing. I've found two good articles on it:

Notebook directories

I use Remind to generate the symlinks from a cron job that runs just after midnight every day:

# mknbdir: make notebook directory for the day.
# should be run just after midnight.
# make symbolic links for today, tomorrow, etc.

export PATH

die () {
    echo "$@" >& 2
    exit 1

cd $HOME
test -d "$top" || die "$top: dir not found"

# Handle pages for today and yesterday.

cur="`date +%Y/%m%d`"
test -d "$top/$cur" || mkdir -p "$top/$cur"
test -d "$top/$cur" || die "unable to make $cur"
test -L yesterday && rm yesterday
test -L today && rm today
ln -s $top/$cur today

# Handle pages for other dates.
# NOTE: "date" must have "-d" option for this to work.

other='yesterday tomorrow sunday monday tuesday wednesday
       thursday friday saturday'

for day in $other
    cur=`date -d "$day 03:00" +%Y/%m%d`
    test -d "$top/$cur" || mkdir -p "$top/$cur"
    test -d "$top/$cur" || die "unable to make $cur"
    test -L $day && rm $day
    ln -s $top/$cur $day

# Keep a year's worth in advance.
# NOTE: must have "remind" installed for this to work.

cd $HOME/$top

echo 'REM MSG daily' |
    remind -s+53 - |
    sed -e 's!^\(....\)/\(..\)/\(..\).*!\1/\2\3!' |
while read dir
    test -d $dir || mkdir -p $dir

exit 0

This script also illustrates using Remind to generate dates without having to worry about leap years and other events. Figure 5 shows how to print this week plus the next 52 weeks.

Printing the next year of weeks
Figure 5. Printing the next year of weeks

Daily agendas

Anything on my to-do list for today goes in a file called agenda under today's notebook directory. The a command simply runs Remind on today's agenda file (Figure 6).

Finding today's agenda
Figure 6. Finding today's agenda

I've also written a slightly more advanced script to display your agenda for the next few days.

The rem script allows me to edit or create new agendas quickly:

# rem: edits the agenda file in today's notebook directory
# (default), or one entered on the command line.  If the
# agenda file doesn't exist, a new one is created.

: ${EDITOR="/usr/bin/vi"}
umask 022


for ac_option
    case "$ac_option" in
        -*) ;;
        *)  afile="$ac_option" ;;

test -e "$afile" || echo "REM MSG new agenda" > $afile
exec $EDITOR $afile
exit 0
Timed pop-up reminders

Suppose that I have a meeting at 2 p.m. in room 205, and I'd like a reminder to show up on my screen 5 minutes before it starts. Figure 7 shows all that it takes. A small program called showcal runs once every minute looking for a file called hhmm.rem in today's notebook directory. If it finds one, it runs the contents through Remind and then to another program that handles screen pop-ups.

Creating a pop-up reminder
Figure 7. Creating a pop-up reminder

What if I want a reminder every day at a certain time? I just put the same type of file in the ~/.calendar directory instead (Figure 8).

Adding a daily reminder
Figure 8. Adding a daily reminder

This reminder will show up at 8:35 p.m. to ensure that I don't miss anything crucial if I happen to be at work late on Sunday or Wednesday. It won't show up on any other days.

Pages: 1, 2, 3, 4, 5, 6, 7

Next Pagearrow

Sponsored by: