I love bash (4.1.2(1)-release) but I strongly prefer the way tcsh implements pushd +N with the dextract option enabled, so much so that I refuse to use bash as my default shell because of it. Has anyone implemented a dextract-like directory stack set of commands in bash or maybe I haven't figured out how to coax bash to behave like tcsh with dextract enabled?
The sticking point: The order that bash leaves the directory stack in after a pushd +N. For example:
$ cd /tmp
$ pushd a
/tmp/a /tmp
$ pushd ../b
/tmp/b /tmp/a /tmp
$ pushd ../c
/tmp/c /tmp/b /tmp/a /tmp
$ pushd +1
/tmp/b /tmp/a /tmp /tmp/c
Why does bash (and default tcsh) rotate the positions of all the other directories when I do a pushd +1? Why is this useful? (Perhaps if someone explained, I might appreciate the behavior and get used to it.) Compare to tcsh with dextract, which just extracts it and puts it on top:
% set dextract
% cd /tmp
% pushd a
/tmp/a /tmp
% pushd ../b
/tmp/b /tmp/a /tmp
% pushd ../c
/tmp/c /tmp/b /tmp/a /tmp
% pushd +1
/tmp/b /tmp/c /tmp/a /tmp
Note that the remaining order of the directories is untouched. I consider this important because it's easier to keep track in my mind when the order doesn't get rotated, and so I don't have to be always doing a dirs and searching for the directory I want.
If I were to take a crack at it, where would I start? I see there is a variable DIRSTACK, but it is not correct (it's empty when the stack has four entries), although changing it does alter the stack (not correctly though).