zsh tips: Changing directories

We all know how to change directories via cd , but zsh has some really neat features implemented to support us in changing directories the smart way.

Changing directories without cd

Because we all like productivity, let’s make cd  itself needless, by enabling auto_cd :

Now as you’ve enabled auto_cd , you can change directories without even typing   cd :

Changing directories with string replacement

Let’s say you change into a complicated path. Then you need to change into a similar path, with a somewhat different substring:

Changing directories with auto completion

I already mentioned it in the last post, auto completion is really helpful in long / complicated directory paths:

Changing to recent directories with z

There’s a project on github called z. This is the absolute “pro-way” to change to most recent used directories.

Basically it will replace / alias your cd command, and then it starts learning. After it has learned about your cd behaviour, you can use z  to jump to your most frequent used directories. And if this isn’t enough, it also support regex.

Let’s say you’ve to move to /some/complicated/path/with/foo/bar  all the time. Instead of cd  into it, you can now z  into it.

If you’ve multiple bar folders, you can specify multiple parts of the path, so that you match the right one:

Awesome, isn’t it? And when you’re using oh-my-zsh like suggested in the zsh: A shell on steroids post, then you just can load the z plugin.

5 Comments

  • ruya yorumu Reply

    At this time it appears like WordPress is the best blogging
    platform out there right now. (from what I’ve read) Is that what you are using on your blog?

    • Dominique Barton Reply

      Hi. Yeah, we’re using WordPress for our blog and I really like it, as it has a huge user base and there are a lot of plugins available. Cheers Domi

  • Canada Kratom Reply

    Vous n’êtes jamais aussi bon que sous la pression ?

    • Dominique Barton Reply

      What? 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.