Mike Schilli's Friendly Neighborhood Perl Shop

Home
USArundbrief.com
Resume
CPAN Modules
Articles in English
Articles in German
Mike's Script Archive
English-Japanese Translation Trainer
Adventures with O'Reilly's Safari
10 Easy Steps to Become a California Driver
Unofficial perlmonks.com IRC Channel
My Collection of Outage Pages
Prisma (Computer Club Deutschland)
The Mike Schilli Monologues
Mike's Monologues
Mike's Script Archive: cdbm

cdbm - Bookmarks for shell directory navigation


NAME

cdbm - Bookmarks for shell directory navigation


DOWNLOAD

cdbm


SYNOPSIS

    cdbm [+-[path]]


DESCRIPTION

cdbm is a bookmark utility for shell directories to releave the shell user from remembering and retyping various directory paths.

When called, cdbm will display a list of path names and let the user choose one by typing the number displayed next to it:

    $ cdbm 
    [1] /apps/NES/https-mike
    [2] /home/mschilli/projects/cdbm
    [3] /usr/lib/perl5/site_perl
    [1-3]>

cdbm by itself its relatively useless. No program executed by the shell is able to change the shell's current directory, cdbm is no exception, because it's executed by the shell in a subprocess. However, in combination with shell aliases and functions (ksh and bash), it unleashes its real power:

    function c () { cd `cdbm`; ls; }

If the shell's initialisation file (.bashrc, .ksh) contains the line above, the newly created 'command' c will first display a list of directories, let the user choose one and then switch to it:

    [/tmp] $ c
    [1] /apps/NES/https-mike
    [2] /home/mschilli/projects/cdbm
    [3] /usr/lib/perl5/site_perl
    [1-3]>2
    /home/mschilli/projects/cdbm
    Makefile.PL eg t blib MANIFEST
    [/home/mschilli/projects/cdbm] $

All that cdbm does is print out the chosen path name, which is then caught by the shell function c, which runs cd on it and effectively carries the user over to the chosen directory, in which it runs a ls command for better orientation.

cdbm stores the path names in the file .cdbmrc in the user's home directory. For convenient access, it offers command line options to add, remove and edit the path collection in .cdbmrc:

    cdbm +/foo/bar/path    # Add a path to the collection
    cdbm -/foo/bar/path    # Remove a path from the list
    cdbm +                 # Add the current path to the list
    cdbm -                 # Remove the current path to the list
    cdbm -e                # Invoke an editor to edit C<.cdbmrc>
    cdbm -h                # Print help page


FILES

    ~/.cdbmrc


THANKS

Thanks to Ralf Mei▀ner for fixing a bug in cdbm_remove() and adding support for sorted lists and more.


LEGALESE

Copyright 2002 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


AUTHOR

2002, Mike Schilli <m@perlmeister.com>


Latest update: 20-Oct-2013