# $Id: book,v 1.4 2003/04/21 18:29:01 jsh Exp jsh $

bm() { eval bm_$1=$PWD; set | grep ^bm_ > $HOME/.book; }
go() { . $HOME/.book; eval cd \$bm_$1; }
bms() {
    if test $# -gt 0 && test $1 == "-r"
    then
	eval $(env | perl -lane 'print if s/^(bm_.*)=.*/unset $1;/')
	> $HOME/.book
    else
	cat $HOME/.book
    fi
}
return

=head1 NAME

bookmark - manage shell-level bookmarks

=head1 SYNOPSIS

    bm [bookmarkname]
    go [bookmarkname]
    bms [-r]

=head1 DESCRIPTION

This suite of utilities manages shell-level bookmarks.

=over 4

=item I<bm [bookmark_name]>

set a bookmark

=item I<go [bookmark_name]>

go to a preset bookmark

=item I<bms>

list the bookmarks

=item I<bms -r>

reset (clear) all bookmarks

=back

Bookmarks are preserved across login sessions and across windows.
One unnamed bookmark is permitted at any time.

(B<Note>: this file must be I<sourced>.  It can't just be executed.)

=head1 FILES

B<$HOME/.book> - list of bookmarks

=head1 EXAMPLES

    # make a series of bookmarks
    $ cd /tmp; bm tmpdir		
    $ cd ~/One/Two/Three/.../Infinity
    $ bm gamow
    $ cd
    $ bm myhome
    $ cd /usr/bin; bm		# set the unnamed bookmark

    # list them
    $ bms
    bm_tmpdir=/tmp
    bm_gamow=/home/jsh/One/Two/Three/.../Infinity
    bm_myhome=/home/jsh
    bm_=/usr/bin

    # try them out
    $ go gamow; pwd
    /home/jsh/One/Two/Three/.../Infinity
    $ go; pwd
    /usr/bin

    # clear them all
    $ bms -r
    $ bms

=head1 SEE ALSO

L<http://alumni.caltech.edu/~copeland/work/simple.html>
L<http://swexpert.com/C9/SE.C9.JUN.01.pdf>

=head1 AUTHOR

    Jeffrey Copeland <copeland@alumni.caltech.edu>
    Jeffrey S. Haemer <jsh@usenix.org>

=cut
