Hack 96 Leave on Time


figs/beginner.gif figs/hack96.gif

Use your terminal's built-in timers and schedulers.

You know how it is. You sit down in front of a keyboard and quickly become absorbed in your work. At some point you remember to look up, only to notice that everyone else is gone for the day. If that doesn't describe you, I bet you can think of at least one person it does describe.

9.9.1 Don't Forget to Leave

Fortunately the leave command can save you from the embarrassment of forgetting important appointments. Use it at any time by typing:

% leave When do you have to leave?

There are three ways to respond to that question:

  • Press Enter to abort.

  • Type hhmm, where hh represents the hour and mm represents the minute.

  • Type +number, where number represents how many hours or minutes from now you'd like to leave.

For example, to leave at 5 PM:

% leave 500 Alarm set for Tue Dec 30 17:00:00 EST 2003. (pid 50097)

leave 1700 will achieve the same results.

Or, to leave in 45 minutes:

% leave +45 Alarm set for Tue Dec 30 9:52:00 EST 2003. (pid 50108)

Be sure to include the + if you're not specifying an actual time.

You can then carry on with your day. Five minutes before it's time to leave, your terminal will beep and display this message:

You have to leave in 5 minutes.

You'll receive another warning one minute before the set time, then every minute thereafter. leave definitely works for the procrastinator and those who always need to do just one more thing before leaving. The only way to end the incessant nagging is to log out or killall leave (but please don't take that last command literally!).

Consider placing /usr/bin/leave in /usr/share/skel/dot.cshrc [Hack #9].

9.9.2 Creating Terminal Sticky Notes

leave is nice for scheduling your own departure, but what if you want to schedule the execution of commands? I bet you're thinking "use at or cron." Have you ever tried the scheduler built into tcsh?

While sched can execute any command at a given time, you can also use it as a reminder system. I use it as a terminal sticky-note system that won't clutter up my monitor. For example, it's 9:00, I've just logged in, and I'm mulling over my to-do list for the day. As I mentally review my list, I type the following:

% sched 11:55 echo Lunch with Robyn today. % sched 2:30 echo Reminder: project due by 4:30. % sched 5:00 echo Go home!!!

Now at any point in the day I can review my to-do list:

% sched 1     11:55    echo Lunch with Robyn today. 2     2:30     echo Reminder: project due by 4:30. 3     5:00     echo Go home!!!

As each appointed time arrives, the desired reminder will appear on my terminal.

To remove an item from your to-do list, simply type sched -#, where # represents the number of that item in the schedule. Logging out of your shell will also remove all items from your list since sched is a shell command.

9.9.3 Saving Your Schedule

What if you plan on logging out during the day? You certainly don't want to recreate your schedule every time you log in. It's a simple matter to save the schedule. Place this line in your ~/.logout file:

sched > schedule

This will send the output of sched to a file in your home directory called schedule, saving any items in your to-do list to the specified file when you log out.

Unfortunately, there's no simple way to pipe that list back into sched when you log back in. This has to do with how the C shell handles its built-in commands. You would think that:

% sched < schedule

would reverse the process, but it doesn't. If you really miss your shell sending you reminders at their appointed times, consider locking your terminal [Hack #7] instead of logging out during the day.

9.9.4 See Also

  • man leave

  • man tcsh



BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net