Collapsing Empty Directories in Zsh

Earlier this month, I wrote about Fuco1’s package to collapse empty directories in dired listings. That’s a handy thing that lets you avoid clicking through a series of empty directories1 to reach the file or directory you really want.

The idea originated with GitHub where Karl Voit noticed it and soon became addicted. He started wishing he could do the same sort of thing in zsh. In particular, he wanted to have cd jump over the empty directories so he didn’t have to list all the intermediate directories. With the help of seanliao96 he offers a nice bit of shell code that does just that.

If you’re a zsh user, you should take a look at Voit’s post and see if you want to adopt his code. As I say, it’s a simple shell function that you can paste into your zshrc.local so it’s easy to experiment with and get rid of if you don’t like it.

Footnotes:

1

By which I mean directories that have only a single entry of another directory.

This entry was posted in General and tagged , . Bookmark the permalink.