z is a utility that allows you to jump around your machine very quickly. It allows you
to change directory by specifying a partial path and it will choose the most relevant one based on your directory
history automatically. It uses an algorithm that's based on "frecency". Directories are ranked by how frequently you
visit them, and how recently the last visit was.
It's a bit tough to explain, so here's an example. I spend most of my time working in three directories:
Instead of typing
cd /var/www/example.com/main/src/application every time I want to work on "example.com", I just need to
cd into it once, and it will add it to my list of visited paths in
z. The next time I want to work in that folder, I can just type
z example and it will jump to the correct path.
Where it gets tricky is when I mean to go to
z thinks I want to go to the application folder. Fortunately,
z lets you specify multiple search values, so if I type
z example and it takes me to the application folder, I can just type
z example test to jump to the tests folder.
If you try and move to a directory that doesn't exist, then
z just won't do anything.
# We want to work on "example.com"vagrant:~$ z example# We didn't mean the application (even though we normally do)# So let's change to the tests directoryvagrant:/var/www/example.com/main/src/application$ z example test# You don't have to specify a full word, just the shortest# string that will match will dovagrant:/var/www/example.com/main/src/test$ z storypl# Let's try and change to a directory that we've never been tovagrant:~/testing/storyplayer/main/src$ z foobar# Nothing happened, we're still in Storyplayervagrant:~/testing/storyplayer/main/src$