Blog posts for Ruby, Ruby on rails and Linux.

Go back to all blogs

Improve your work flow : auto cd paths in zsh

Kapil Raj Nakhwa2016-Jan-27

So thing is we developers want to improve our workflow and keep our repeating tasks to minimum daily so that we would are more efficient much like the code we write down . If you are like me you are probably involved in more projects that you can remember and organize. 

The first step I tried to organize by ruby and ruby on rails projects were to have some kind of folder structure . 

I put all my stuffs inside my ~/dev directory 

I put all the development works that I do under jyaasa to ~/dev/jyaasa/ and all my hobby projects to ~/hobby directory . My tools that i build for myself would usually be in ~/dev/tools directory .

This is what most of the jyaasians that I work with do as well. or at-least are close to doing the same. 

However, every time I have to switch a project or even go inside a project from firing the terminal first time for the day . 

I still have to do manual stuffs like ~/dev/jyaasa/thepact  

And if I have remember to add something to our emitii codebase . I would be doing something like this. 

$dev/jyaasa/thepact : - cd ../emitii

It is quite time consuming and drains a little bit of mental energy every time I have to switch context. 

With zsh ’s auto_cd option I should not have been doing that so all these years . and I realized How stupid I was to be doing that . just contemplating on all the lost time from my life doing this for so many years.  

Let’s get started to it. 

In your

~/.zshrc

add these 

setopt auto_cd
cdpath=($HOME/dev/jyaasa $HOME/mydirectoryofinterest2;)

Now all i need to do is 

$:- thepact

and I can go into the project 

similarly if I have to switch into the emitii codebase. All I need to do now is 

$:- emitii

This way it does not matter where I am . I can easily get inside the root directory of any rails app or any other project that I am working on. 

I can already feel extra minutes at the end of my day now. 


Tags: zsh,workflow,productivity,zen

Go back to all blogs
Never miss a post on new ruby and rails tips