[IPython-user] Rethinking directory history

Ville Vainio vivainio at gmail.com
Tue Apr 11 11:11:28 CDT 2006

I've been thinking about reimplementing the directory history
(accessed e.g. via "cd -3", which means "go to dir that was selected 3
cd's ago") in a way that would make it more useful and intuitive. I
find it very hard to wrap my head around the current line of thinking,
esp. since every cd "shifts" the directory history, so "cd -3" means a
different thing at different times. Not to mention that the directory
changed to by "cd -3" is also pushed to the directory history!

Here's what I'm thinking about:

ipython]|15> cd
home]|16> cd /
\]|17> cd tmp/
tmp]|18> ls


[tmp]|19> cd /bin/

Now, if I said "cd -18", it would jump to /tmp. "cd -17" would jump to /, etc.

cd -n would jump to the directory where *the prompt number n was in*.
This way, cd -45 would always mean the same directory in the directory
history, throughout the current ipython session. It's also easy to
scan back the screen to find the prompt that is in the directory you
want. Rerunning the command from input history often doesn't cut it,
because cd commands are typically relative.

Of course "cd -" would still jump to the previous directory, but it's
pretty much the only intutive use of directory history atm, at least
for me.

I also think that we should use Walter's ipipe curses browser to make
an easy "directory selector", to provide a graphical way to change
dirs (in the history) easily.

Ville Vainio - vivainio.googlepages.com
vainio.blogspot.com - g[mail | talk]='vivainio'

More information about the IPython-user mailing list