z is the new j, yo!

Today I was casually browsing /r/vim where one of the redditors made a z plugin for vim. If you never heard of z before — I bet it will improve your life by at least 9000%.

First: z is a shell script that can be included in your bashrc. Download, edit bashrc, source path/to/z.sh and restart your Terminal to get going.

Link to the z project: https://github.com/rupa/z

What does z do?

I frequently work in a couple of projects and I always have to cd into them. I have frequently edited the lychee.js’ lychee library:

cd /opt/lycheejs;
cd ./libraries/lychee;
vim; # or whatever to work here

So here’s the deal. cd ing into a folder is nagging and annoying. bash autocomplete is nice, but often you have similar starting names and you basically need to cd into it again, because you didn’t expect it.

z on the other hand maintains a history of commonly cd ed folders (or PWDs of bash instances) — and more importantly — sorts them by frequency.

That means commonly cd’ed folders are first and are preferred. It also parses them recursively, so you can fuzzy-jump around when you know there’s only one subfolder in the tree with that specific name.

# old method
cd /opt/lycheejs;
cd ./libraries/lychee;
vim; # or whatever
# new method
z lycheejs lychee;
vim; # or whatever

Pretty awesome, hugh?

Even more awesome is the guy that put out a z.vim plugin for it, so you can now fuzzy-jump around inside VIM: https://github.com/lingceng/z.vim

So, that’s it for today. Nevertheless just a casual post. Over and out.