Directory Management with cd
Posted by Dave Eddy on Sep 14 2013 - tags: techYou
cd
around like you normally would, and the directories are pushed into a stack. Use the functions
to view the stack of directories, and runs "$num"
tocd
into the directory listed. Useb
to jump back 1 directory.
I was inspired by this article written by Derek Wyatt about directory
management in BASH. The code I’ve written for this accomplishes most of the same tasks,
but does so with about 1/3 of the code, as this was written specifically for BASH (no
legacy KSH bits) and doesn’t implement any of the fancier features for cd
.
Example
In the above example I cd
around a bit, and then run s
to see what the current
stack looks like. The current stacks shows all of my previous directories in reverse order
(limited to $CD_STACK_MAX
entries, which defaults to 15).
The code is on GitHub here https://github.com/bahamas10/bash-cdstack