1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
|
@c $Id: reminders.texinfo,v 1.23 2002/01/09 17:00:37 m Exp m $
@node Reminders, Mathematics, Platform Conversions, Productivity
@comment node-name, next, previous, up
@chapter Reminders
@cindex reminders
@noindent
If you're working on a system on a regular basis, it can be very useful
to have the system remind you when you should be doing something
else. This chapter describes software tools that provide
reminders---clocks, calendars, address books, and tools for tracking
appointments.
@menu
* Date and Time:: Getting the date and time.
* Saytime:: Hearing the current time.
* Calendars:: Displaying a calendar.
* Appointments:: Keeping track of appointments.
* Contact Managers:: Using a contact manager.
* Self Reminders:: Reminding yourself
@end menu
@node Date and Time, Saytime, Reminders, Reminders
@comment node-name, next, previous, up
@section Displaying the Date and Time
@cindex displaying the date and time
@cindex date, displaying the
@cindex time, displaying the
@cindex Network Time Protocol (NTP)
@pindex date
@pindex chrony
@flushleft
@sf{WWW}: @url{http://www.clock.org/}
@sf{WWW}: @url{http://www.eecis.udel.edu/~ntp/}
@end flushleft
@*
@noindent
Use @code{date} to output the current system date and time.
@itemize @bullet
@item
To output the current system date and time, type:
@example
@cartouche
$ @kbd{date @key{RET}}
Fri May 11 11:10:29 EDT 2001
$
@end cartouche
@end example
@end itemize
The default format of the output is to display the day of the week; the
month name; the day of the month; the 24-hour time in hours, minutes,
and seconds; the time zone; and the year.
Use the @samp{-u} option to output the current date and time in
Greenwich Mean Time (also known as Coordinated Universal Time, or UTC).
@itemize @bullet
@item
To output the current date and time in UTC, type:
@example
@cartouche
$ @kbd{date -u @key{RET}}
Fri May 11 15:10:29 UTC 2001
$
@end cartouche
@end example
@end itemize
Use the @samp{-R} option to output the date in the format described in
RFC822 (@pxref{Reference Files, , Word Lists and Reference Files}): day
of week followed by day of month, month name, year, time, and time zone
in numeric format. This is the date format used in email messages.
@itemize @bullet
@item
To output the current date and time in RFC822 format, type:
@example
@cartouche
$ @kbd{date -R @key{RET}}
Fri, 11 May 2001 11:10:29 -0400
$
@end cartouche
@end example
@end itemize
You can also use the @samp{-d} option to specify the precise fields to
output, and the order in which to output them. One useful example is
given next; for more information, see the @code{date} @code{man} page
(@pxref{Man, , Reading a Page from the System Manual}).
To output the number of days into the year for a particular date, use
@samp{-d} with @kbd{'@var{DD MMM}' +%j}, where @samp{DD} is the day of
month and @samp{MMM} is the name of month.
@itemize @bullet
@item
To output the numeric day of the year that 21 June falls on in the
current year, type:
@example
@cartouche
$ @kbd{date -d '21 Jun' +%j @key{RET}}
172
$
@end cartouche
@end example
@end itemize
This command outputs the number 172, which indicates that 21 June of the
current year is the 172nd day of the current calendar year.
@sp .25
@noindent
@strong{NOTE:} To ensure that the time on your system clock remains as
accurate as possible, your system administrator should install the
@file{chrony} package; it periodically adjusts the time on the system
clock according to measurements obtained from other servers on the
Internet via ``Network Time Protocol.''
@node Saytime, Calendars, Date and Time, Reminders
@comment node-name, next, previous, up
@section Playing an Audible Time Announcement
@cindex playing an audible time announcement
@cindex time, audible output of the
@pindex saytime
@flushleft
@sf{Debian}: @file{saytime}
@sf{WWW}: @url{http://www.acme.com/software/saytime/}
@end flushleft
@*
@noindent
Use the @code{saytime} command to output the current system time in an
audible message in a male voice. You must have a sound card installed
on your system, and it must be set up with speakers or some other output
mechanism at an appropriate volume level in order for you to hear it
(@pxref{Audio Settings, , Adjusting the Audio Controls}).
@itemize @bullet
@item
To hear the current system time, type:
@example
$ @kbd{saytime @key{RET}}
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} If you're feeling adventurous, you can record another
voice---like your own---and use that voice instead of the default voice;
the sound files used are Sun @file{.au} files and are kept in the
@file{/usr/share/saytime} directory.
@node Calendars, Appointments, Saytime, Reminders
@comment node-name, next, previous, up
@section Calendars
@cindex calendars
@noindent
The following recipes describe a few of the basic tools for displaying
calendars in Linux.
@menu
* Calendar Display:: Displaying a calendar.
* Emacs Calendar:: Emacs calendar service.
@end menu
@node Calendar Display, Emacs Calendar, Calendars, Calendars
@comment node-name, next, previous, up
@subsection Displaying a Calendar
@cindex displaying a calendar
@cindex calendar, displaying a
@pindex cal
@noindent
The @code{cal} tool outputs a calendar to the standard output. By
default, it outputs a calendar of the current month.
@itemize @bullet
@item
To output a calendar for the current month, type:
@example
$ @kbd{cal @key{RET}}
@end example
@end itemize
To output a calendar for a specific year, give just the year as an
option.
@itemize @bullet
@item
To output a calendar for the year 2001, type:
@example
@cartouche
$ @kbd{cal 2001 @key{RET}}
2001
January February March
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 5 6 1 2 3 1 2 3
7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10
14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17
21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24
28 29 30 31 25 26 27 28 25 26 27 28 29 30 31
April May June
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 5 6 7 1 2 3 4 5 1 2
8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9
15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16
22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23
29 30 27 28 29 30 31 24 25 26 27 28 29 30
July August September
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 5 6 7 1 2 3 4 1
8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8
15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15
22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22
29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29
30
October November December
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 5 6 1 2 3 1
7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8
14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15
21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22
28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29
30 31
$
@end cartouche
@end example
@end itemize
Use the @samp{-y} option to output a calendar for the current year.
@itemize @bullet
@item
To output a calendar for the current year, type:
@example
$ @kbd{cal -y @key{RET}}
@end example
@item
So, to print out a calendar for the current year to the default printer,
type:
@example
@kbd{cal -y | lpr @key{RET}}
@end example
@end itemize
To output a calendar for a specific month, give both the numeric month
and year as arguments.
@itemize @bullet
@item
To output a calendar for June 1991, type:
@example
@cartouche
$ @kbd{cal 06 1991 @key{RET}}
June 1991
S M Tu W Th F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
$
@end cartouche
@end example
@end itemize
@node Emacs Calendar, , Calendar Display, Calendars
@comment node-name, next, previous, up
@subsection Displaying a Calendar in Emacs
@cindex displaying a calendar in Emacs
@cindex calendar, displaying in Emacs
@cindex Emacs, displaying a calendar in
@pindex emacs
@noindent
Emacs comes with its own calendar service. The @code{calendar} function
displays a three-month calendar in a new buffer---it gives the current,
previous, and next months, and it puts point on the current date. To
select the month and year to display, preface the @code{calendar}
function with the @code{universal-argument} command, @kbd{C-u}.
@itemize @bullet
@item
In Emacs, to display a three-month calendar for the current month and
year, type:
@example
$ @kbd{M-x calendar @key{RET}}
@end example
@item
In Emacs, to display a three-month calendar for August 2010, type:
@example
@kbd{C-u M-x calendar @key{RET}}
Year (>0): 2001 @kbd{@key{BKSP} @key{BKSP} 10 @key{RET}}
Month name: @kbd{Aug @key{RET}}
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} When you display a calendar for a specific month and
year, Emacs fills in the current year in the minibuffer; in the example
above, the current year was 2001, and @key{BKSP} was typed twice to
erase the last two digits, which were replaced with @samp{10} to make it
the year 2010.
@node Appointments, Contact Managers, Calendars, Reminders
@comment node-name, next, previous, up
@section Managing Appointments
@cindex managing appointments
@cindex appointments, managing
@cindex Emacs diary
@pindex calendar
@pindex emacs
@flushleft
@sf{Debian}: @file{bsdmainutils}
@end flushleft
@*
@noindent
The @code{calendar} tool is a reminder service that you can use to
manage your appointments. It reads a @dfn{calendar file}, which is a
text file in the current directory containing a list of appointments and
reminders; then it outputs those entries from the file that have today
or tomorrow's date. (On a Friday, it outputs entries for that weekend
and for the following Monday.)
For example, if today is Friday, June 16, and you run @code{calendar} in
the same directory as your calendar file, typical output might look like
this:
@example
@cartouche
$ @kbd{calendar @key{RET}}
6/16 Finish draft of book
Party at Jack's
Fri Lunch with Kim and Jo, 12:30
Mon Book manuscript due
$
@end cartouche
@end example
The @code{calendar} tool reportedly first appeared in Version 7 of AT&T
UNIX, and was rewritten early on for the BSD family of Unix. While the
BSD derivate is available for Debian as part of the @code{bsdmainutils}
package, this tool isn't yet standard on all Linux distributions.
The following are recipes for writing your calendar files, including
other calendar files in your own calendar file, and for automating
the delivery of your reminders.
@sp .25
@noindent
@strong{NOTE:} Emacs has its own equivalent to this tool, which it calls
the ``Diary.'' @inforef{Diary, The GNU Emacs Manual, emacs-e20.info} for
more information on this feature.
@menu
* Appointment Format:: Making an input calendar files.
* Appointment Inclusion:: Including other calendars in yours.
* Automating Appointments:: Automating the delivery of your appointments.
@end menu
@node Appointment Format, Appointment Inclusion, Appointments, Appointments
@comment node-name, next, previous, up
@subsection Making an Appointment File
@cindex making an appointment file
@cindex appointment file, making
@cindex calendar file, making
@pindex calendar
@noindent
To begin using @code{calendar}, you need to make a ``calendar file''
where you can enter your appointments. It's just a plain text file, and
can be called either @file{calendar} or @file{.calendar}; the latter
makes it a ``hidden'' file, as described in @ref{Listing Hidden, ,
Listing Hidden Files}.
Write each appointment or calendar entry on a line by itself; blank
lines in the file are ignored. The format of a calendar entry is as
follows:
@example
@var{[date]} @var{[tab or spaces]} @var{[text of reminder itself]}
@end example
Just about every common date style is recognized. For example, the
following are all valid dates for the fourth of July:
@example
7/4
July 4
4 July
Jul. 4
Jul 4
@end example
Entries aren't constrained to a single day, either; you can have entries
for a day of the week or for a certain month---@samp{Mon} or
@samp{Monday} for every Monday; @samp{Jun} or @samp{June} for the first
day of every June. You can use an asterisk as a wildcard: @samp{*/13}
reminds you of something on the thirteenth of every month. When the date
is omitted on a line, the date of the preceding appointment is assumed.
For example, suppose you have a file called @file{calendar} in your home
directory that looks like this:
@example
6/16 Finish draft of book
Party at Jack's
6/20 Gallery reading
Fri Lunch with Kim and Jo, 12:30
Mon Book manuscript due
@end example
If the current date is 16 June, a Friday, and you run @code{calendar} in
your home directory, you'll get the same output as in the example in the
previous section, @ref{Appointments, , Managing Appointments}.
@sp .25
@noindent
@strong{NOTE:} In the example above, the entry for the party doesn't
have a date on it---it used the date of the preceding entry,
@samp{6/16}.
@node Appointment Inclusion, Automating Appointments, Appointment Format, Appointments
@comment node-name, next, previous, up
@subsection Including Holidays in Your Reminders
@cindex including holidays in your reminders
@cindex holidays, including in your reminders
@cindex reminders, including holidays in your
@cindex calendar files, including
@pindex calendar
@noindent
The @code{calendar} package comes with a collection of prepared calendar
files for many kinds of holidays and other occasions, which you can
reference in your own calendar file to include their entries in your
own reminders.
The prepared files are stored in @file{/usr/share/calendar}. The
following table gives the name of each calendar file and describes its
contents.
@multitable @columnfractions .30 .70
@item @sc{Calendar File}
@tab @sc{Description}
@item @code{calendar.birthday}
@tab Births and deaths of famous people.
@item @code{calendar.christian}
@tab Christian holidays.
@item @code{calendar.computer}
@tab Significant dates in the history of computing.
@item @code{calendar.history}
@tab Dates of U.S.@: historical events.
@item @code{calendar.holiday}
@tab Standard and obscure holidays.
@item @code{calendar.judaic}
@tab Jewish holidays.
@item @code{calendar.music}
@tab Dates related to music, mostly 1960s rock and roll.
@item @code{calendar.usholiday}
@tab U.S.@: holidays.
@item @code{calendar.hindu}
@tab Hindu holidays.
@end multitable
To have @code{calendar} output dates from one of these files along with
your usual appointments, put the following in your calendar file, where
@var{file} is the name of the particular calendar file you want to
include:
@example
#include <@var{file}>
@end example
For example, to output both US holidays and famous births and deaths
when you run @code{calendar}, put these lines somewhere in your calendar
file:
@example
#include <calendar.usholiday>
#include <calendar.birthday>
@end example
NOTE: You can, of course, share your own calendar files with other
users; this is useful for making special calendars for a group or
organization. If the calendar file is in the current directory or
@file{/usr/share/calendar}, you can just give the file name; otherwise,
give its full path name in the @code{include} statement.
@node Automating Appointments, , Appointment Inclusion, Appointments
@comment node-name, next, previous, up
@subsection Automatic Appointment Delivery
@cindex automatic appointment delivery
@cindex appointments, automatic delivery of
@cindex cron jobs, scheduling
@pindex calendar
@pindex mail
@pindex crontab
@noindent
You can automate your appointment service so that your appointments and
reminders are delivered each time you log in or start a new shell, or
you can have the day's reminders emailed to you each morning.
Add @code{calendar} to your @file{.bashrc} file to output the
day's appointments and reminders every time you log in or start a new
shell (@pxref{Bash Login, , Customizing Future Shells}).
If you keep your calendar file in a directory other than your home
directory, make sure that @code{calendar} (the tool) is called from that
directory. For example, if your calendar file is in your
@file{~/doc/etc} directory, you'd put the following line in your
@file{.bashrc} file:
@example
cd ~/doc/etc; calendar; cd
@end example
To have the system send you the day's appointments in email, use
@code{crontab} to schedule a daily @dfn{cron job} process which runs
@code{calendar} and, if there is any output, mails it to you with
@code{mail}.
To do this, add the following line to your @file{crontab} file (if you
don't have one, just put this line in a text file called @file{crontab}
somewhere in your home directory):
@example
45 05 * * 1-5 calendar | mail -s 'Your Appointments' joe@@example.org
@end example
The @samp{45 05 * * 1-5} specifies that these commands be run at 5:45
a.m. on every weekday. The rest of the line is the series of actual
commands that are run: the @code{calendar} tool is run on your personal
calendar file, and if there is any output, it's mailed to
joe@@example.org (replace that with your actual email address, or with
your username on your local system if you check mail there).
Add this new @code{crontab} entry to the @code{cron} schedule by running
the @code{crontab} tool with the name of your @file{crontab} file as an
argument.
@itemize @bullet
@item
To add the new entry in the file @file{crontab} to the @code{cron}
schedule, type:
@example
$ @kbd{crontab crontab @key{RET}}
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} The name of the command, @code{crontab}, is the same as
the file, @file{crontab}.
@node Contact Managers, Self Reminders, Appointments, Reminders
@comment node-name, next, previous, up
@section Contact Managers
@cindex contact managers
@cindex rolodexes
@noindent
Loosely put, a @dfn{contact manager} is a piece of software that helps
you keep track of information about people you may need to contact in
the future. In the past, people often called the physical embodiment of
these things a ``rolodex,'' which incidentally was a brand name for the
Cadillac of such contact managers, the circular Rolodex file that sat
atop the desk of every successful 20th century businessman. I hear that
many people use them even today; the following recipes show how it can
be done in Linux with less desk space and faster search times.
@menu
* Address List:: A free-form address list.
* BBDB:: A contact manager database in Emacs.
@end menu
@node Address List, BBDB, Contact Managers, Contact Managers
@comment node-name, next, previous, up
@subsection Keeping a Free-Form Address List
@cindex keeping a free-form address list
@cindex free-form address list, keeping a
@pindex grep
@pindex emacs
@pindex less
@noindent
The simplest way to keep names and addresses in Linux is to keep them in
a text file as a free-form address list; to find an entry, use the
search capabilities of tools like @code{grep}, @code{less}, and Emacs.
This method is useful for when you need to keep track of name and
address information of many parties, and don't always keep the same kind
of information for each---maybe sometimes a name and phone number,
sometimes just a mailing address, sometimes a name and email
address. With a free-form address list, each entry contains whatever
information you have in the format you want.
Separate the entries with a delimiter line of your preference. I happen
to use @samp{###}, but you can use whatever characters you're
comfortable with---just make it a combination that won't appear in the
text for any of the entries themselves.
For example, suppose you have a text file, @file{rolo}, containing three
entries:
@example
John Dos Passos
1919 America Ave.
New York City
###
Scott F. - 602 555 1803
(don't call after 12)
###
T. Wolfe's new email has changed.
The new one is: tw@@example.com
@end example
Notice that each entry contains varied information, and is in no
particular format. That's the benefit of a free-form list---you don't
have to type in the entries in any particular order, and you're not
bound by a given set of ``fields''; you can even cut and paste text into
it from email, the Web, or other windows (@pxref{Selecting Text, ,
Selecting Text}).
There are several ways to find text in such a file. Suppose, for
example, you want to contact your friend Scott, and you need his
telephone number.
@itemize @bullet
@item
To output the line in the file containing the text @samp{scott},
regardless of case, type:
@example
@cartouche
$ @kbd{grep -i scott rolo @key{RET}}
Scott F. - 602 555 1803
$
@end cartouche
@end example
@end itemize
This works nicely when the information you need is on the same line as
the information you search for---here, the name Scott is on the same
line as the telephone number; however, the output did not show the
warning that appears on the next line in the file. And what about when
the term you search for and the information you need are on adjacent
lines?
Use the @samp{-C} option with @code{grep} to output several lines of
context before and after matched lines.
@itemize @bullet
@item
To output the several lines around the line matching the text
@samp{olfe}, type:
@example
@cartouche
$ @kbd{grep -C olfe rolo @key{RET}}
T. Wolfe's new email has changed.
The new one is: tw@@example.com
$
@end cartouche
@end example
@end itemize
Another way to search such a file is to open it as a buffer in Emacs and
use any of the Emacs searches. The Emacs @code{incremental-search}
function, @kbd{C-s}, is very useful for such files---even for very large
ones. If you do such a search on a large file, and the first result
doesn't turn up the right record, just keep typing @kbd{C-s} until the
right one appears. If you type the letters to search for in all
lowercase, Emacs matches those letters regardless of case.
@itemize @bullet
@item
To search through the current buffer in Emacs for the first entry
containing the text @samp{New York}, regardless of case, type:
@example
@kbd{C-s new york}
@end example
@item
To search for the next entry containing the text @samp{New York},
regardless of case, type:
@example
@kbd{C-s}
@end example
@end itemize
You can repeat the second example as many times as you wish to show all
entries in the entire buffer with the text @samp{New York} in them. Once
you reach the end of the buffer, type @kbd{C-s} again to loop around to
the beginning of the buffer and continue the search from there. (The
minibuffer will tell you when you've reached the end of the buffer, and
will remind you to type this if you want to loop the search.)
@sp .25
@noindent
@strong{NOTE:} It's also useful to peruse and search through these kind
of files with @code{less}---see @ref{Less Search, , Searching Text in
Less}.
@node BBDB, , Address List, Contact Managers
@comment node-name, next, previous, up
@subsection Keeping a Contact Manager Database
@cindex keeping a contact manager database
@cindex contact manager database, keeping a
@pindex bbdb
@pindex emacs
@flushleft
@sf{Debian}: @file{bbdb}
@sf{WWW}: @url{http://pweb.netcom.com/~simmonmt/bbdb/index.html}
@end flushleft
@*
@noindent
The Insidious Big Brother Database is a contact manager tool for use
with Emacs. You can use it with Emacs email and news readers; it stores
contact information in @dfn{records}, and allows you to search for
records that match a regular expression, as well as records whose
particular @emph{fields} match a regular expression (@pxref{Regexps, ,
Regular Expressions---Matching Text Patterns}).
There are several ways to add a record to the database. Use the
@code{bbdb-create} function to manually add a record (when you run this
command, @code{bbdb} prompts you to enter the relevant information for
each field). When in a mail reader inside Emacs, type a colon (@samp{:})
to display the record for the author of the current message; if there is
none, @code{bbdb} asks whether or not one should be created.
@itemize @bullet
@item
To create a new @code{bbdb} record from scratch, type:
@example
@kbd{M-x bbdb-create @key{RET}}
@end example
@item
To add a new @code{bbdb} record for the author of the current email
message, type:
@example
@kbd{:}
@end example
@end itemize
Use the @code{bbdb} function to search for records---it takes as an
argument the pattern or regexp to search for.
@itemize @bullet
@item
To output records containing the text @samp{scott} anywhere in the
record, type:
@example
@kbd{M-x bbdb @key{RET} scott @key{RET}}
@end example
@end itemize
There are additional functions that let you narrow your search to a
particular field: @code{bbdb-name}, @code{bbdb-company} ,
@code{bbdb-net}, and @code{bbdb-notes}, which respectively search the
name, company, email address, and notes fields.
@itemize @bullet
@item
To output records matching the regexp @samp{*\.edu} in the email
address, type:
@example
@kbd{M-x bbdb-net @key{RET} *\.edu @key{RET}}
@end example
@end itemize
@node Self Reminders, , Contact Managers, Reminders
@comment node-name, next, previous, up
@section Reminding Yourself of Things
@cindex reminding yourself of things
@noindent
Sometimes, it's useful to make a reminder for yourself that you'll see
either later in your current login session, or the next time you log
in. These recipes describe the best ways to do this.
@sp .25
@noindent
@strong{NOTE:} When you want to give yourself a reminder for a future
appointment, use @code{calendar} (@pxref{Appointments, , Managing
Appointments}).
@menu
* Self Emails:: Sending yourself email.
* Leave:: Telling you when it's time to go.
* Delay Command:: Running a command on a delay.
@end menu
@node Self Emails, Leave, Self Reminders, Self Reminders
@comment node-name, next, previous, up
@subsection Sending Yourself Email Reminders
@cindex sending yourself email reminders
@cindex email reminders, sending yourself
@pindex mail
@noindent
Sending yourself a short email message is often effective for reminding
yourself to do something during your next workday or next time you read
mail; keeping a message in your INBOX works as a constant reminder to
get something done---provided you don't abuse it and fill your INBOX
with lots of these ``urgent'' mails!
To quickly send an email reminder, give your email address (or just your
username on your local system, if you check mail there) as an argument to
@code{mail} tool. You'll be prompted to give a subject for the message,
and if that isn't enough space for the reminder, you can write as many
lines as you need below it as the message body text; type @kbd{C-d} on a
line by itself to send the mail.
@itemize @bullet
For example, if your username on your local system is @code{joe}, to
send yourself an email reminder, you'd type:
@example
@cartouche
$ @kbd{mail joe @key{RET}}
Subject: @kbd{Bring files to meeting @key{RET}}
@kbd{C-d}
Cc: @kbd{@key{RET}}
Null message body; hope that's ok
$
@end cartouche
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} For more about using the @code{mail} tool, see
@ref{Sending Mail, , Sending Mail}.
@node Leave, Delay Command, Self Emails, Self Reminders
@comment node-name, next, previous, up
@subsection Reminding Yourself When You Have to Leave
@cindex reminding yourself when you have to leave
@cindex leave, reminding yourself when you have to
@pindex leave
@flushleft
@sf{Debian}: @file{leave}
@sf{WWW}: @url{http://www.debian.org/Packages/stable/utils/leave.html}
@end flushleft
@*
@noindent
Use the @code{leave} tool to remind yourself when you have to
leave. Give as an argument the time when you have to go, using the
format of @var{hhmm}, where @var{hh} is hours in 24-hour format and
@var{mm} is minutes.
@itemize @bullet
@item
To remind yourself to leave at 8:05 p.m., type:
@example
$ @kbd{leave 2005 @key{RET}}
@end example
@end itemize
When you run @code{leave} with no arguments, it prompts you to enter a
time; if you just type @key{RET} then @code{leave} exits without setting
the reminder. This method is good for adding @code{leave} to scripts or
to your @file{.bashrc}, so that you may interactively give a time to
leave, if desired, when the script runs (@pxref{Bash Login, ,
Customizing Future Shells}).
@sp .25
@noindent
@strong{NOTE:} @code{leave} will output a reminder on the terminal
screen five minutes before the given time, one minute before the time,
at the time itself, and then every minute subsequently until the user
logs off.
@node Delay Command, , Leave, Self Reminders
@comment node-name, next, previous, up
@subsection Running a Command on a Delay
@cindex running a command on a delay
@cindex command, running on a delay
@cindex delay, running a command on a
@pindex sleep
@noindent
The @code{sleep} tool does nothing but wait (or ``sleep'') for the
number of seconds specified as an argument. This is useful for ringing
the system bell, playing a sound file, or running some other command at
your terminal after a short delay.
To do this, give the number of seconds to ``sleep'' for as an argument
to @code{sleep}, followed by a semicolon character
(@samp{;})@footnote{The shell command separator; see @ref{Multiple
Commands, , Running a List of Commands}.} and the command(s) to
run. This runs the given command(s) only after @code{sleep} waits for
the given number of seconds.
Since the shell where you type this command will be unusable until the
commands you give are executed (or until you interrupt the whole thing),
type this command in an @code{xterm} or virtual console window
(@pxref{Console, , Console Basics}) other than the one you are working
in.
@itemize @bullet
@item
To ring the bell in five seconds, type:
@example
$ @kbd{sleep 5; echo -e '\a' @key{RET}}
@end example
@item
To announce the time in thirty seconds, type:
@example
$ @kbd{sleep 30; saytime @key{RET}}
@end example
@end itemize
You can also give the time in minutes, hours, or days. To do this,
follow the argument with a unit, as listed in the following table.
@multitable @columnfractions .30 .70
@item @sc{Unit}
@tab @sc{Description}
@item @code{s}
@tab Seconds.
@item @code{m}
@tab Minutes.
@item @code{h}
@tab Hours.
@item @code{d}
@tab Days.
@end multitable
@itemize @bullet
@item
To announce the time in exactly five minutes, type:
@example
$ @kbd{sleep 5m; saytime & @key{RET}}
@end example
@end itemize
|