[nSLUG] Directory Maven
j.maxuel at gmail.com
Wed Apr 5 22:38:14 ADT 2017
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:
cd `find . -type d -name $1 -print -quit 2> /dev/null`;
For bash users (in .bashrc) - smarter method:
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:
find . -type d -name "$argv" 2> /dev/null > ~/.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:
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
"One should strive to achieve, not sit in bitter regret."
- Ronan Harris / Mark Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nSLUG