artathack.com

about web and mobile development

iTerm2: Stay in the Same Directory

I use iTerm2 for about a year now but recognized one “hidden” handy feature just some days ago.

If you cd in a directory where you might want to run a server, run your tests, use your VCS of choice and so on you need to open the same directory over and over again in your tabs or split panes. Open a new Tab and cd to the same directory all the time is very wasteful. So I´ve written a script which does that for me and bundled it with Spark so I just needed to type a shortcut to open a new Tab and cd to my current directory.

BUT with iTerm2 you can achive this behaviour very easily:

Go to Preferences -> Profiles -> General -> Working Directory -> Advanced Configuration -> Edit

first

Then you´ll be in this menu:

second

And change the Radio Button to Reuse previous session´s directory and you´ll get the automatic cd of your current directory for free!

UPDATE:

If you use zsh & RVM you want to add this line to your .zshrc:

__rvm_project_rvmrc

https://rvm.io/integration/zsh/

Comments