Opening a new iTerm tab with the current directory

May 29, 2017 | Personal Projects

This has bothered me since I started using the terminal. While I love using iTerm2, I found it annoying that there was no way to open a tab using the current directory. I find myself doing this frequently as I’ll run multiple tabs for a project – one for background tasks like running servers or compiling SASS files, another for running sandboxes to play around with code, and maybe a third for running various commands (Git, etc).

I was previously using a custom BASH function I built, but it required multiple steps to copy the working directory, open a new tab, then cd with the the copied directory. It worked okay, but it certainly needed to be improved.

With the help of Stack Overflow, I’ve found a good enough solution that involves using OSA Script. Check out the code below:

Check out the Gist here.

Found this useful? Feel free to use it! If you’ve found a better way to do this, let me know in the comments.