[nSLUG] Directory Maven

Joel Maxuel j.maxuel at gmail.com
Wed Apr 5 22:38:14 ADT 2017

Hi all,

At this past social meeting, Richard and I sat down and shared some notes
and files regarding DOS, and running it in VirtualBox.  One of the programs
that really caught my eye is Directory Maven.  This program allows you to
change directory to any location on the drive, at the command line, by
typing a single keyword as parameter (as in, does not need the whole

I was curious if this could be duplicated or at least mimicked in some way,
I think I have something of interest now, called "cdb" or Change Directory

For bash users (in .bashrc) - dumb method:

cdb() {
       cd `find . -type d -name $1 -print -quit 2> /dev/null`;

For bash users (in .bashrc) - smarter method:

cdb() {
        find . -type d -name "$1" 2> /dev/null > ~/.config/dirmaven.tmp ;
        dirmaven ~/.config/dirmaven.tmp ;
        cd `cat ~/.config/dirmaven.tmp` ;

For fish (in ~/.config/fish/functions/cdb.fish) - smarter method:

function cdb
    find . -type d -name "$argv" 2> /dev/null > ~/.config/dirmaven.tmp ;
    dirmaven ~/.config/dirmaven.tmp
    cd (cat ~/.config/dirmaven.tmp) ;

The smarter method(s) require a program in your path...source code linked

The "dumb" method automatically chooses the first result.  The "smarter"
method allows you to choose from up to 16 results.  Also, there seems to be
basic expressions (wildcards) in both, but in fish you have to quote the
parameter or an error will occour.


joel at cybaryme ~> cdb "*8916*"
Multiples found.  Pick a directory:
1. ./Build/github/proprietary_vendor_asus/msm8916-common
3. ./Build/github/android_device_asus_msm8916-common
4. ./Build/github/android_kernel_asus_msm8916
#?: 3
joel at cybaryme ~/B/g/android_device_asus_msm8916-common> cdb sepolicy
joel at cybaryme ~/B/g/a/sepolicy>

Only caveat I have left (besides the quotes for fish thing) is that it can
be quite slow if very high up in the directory tree (like /home or /).

Also, I know there is a potential bug with my pascal code, if anything but
a number is typed in.  I may get around to type/error handling.

Finally, if you want to pick this for yourself, you are free to do anything
with it.


Joel Maxuel

"One should strive to achieve, not sit in bitter regret."
 - Ronan Harris / Mark Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170405/3778a997/attachment.html>

More information about the nSLUG mailing list