If you do a lot of context switching between projects, recreating your terminal environment & window layout can easily eat up hours of your day. Here’s a quick tip to help you create and manage persistent terminal workspaces so that with a few keystrokes, you can jump straight back into whatever you were working on as quickly as possible.
How it works
The whole idea behind this setup is to make it so you will have 1) The ability to name your terminal workspaces with easily memorizable names and 2) the ability to keep persistent terminal workspaces running even if you’ve closed your terminal window.
All of this is achieved with the following shell script which we’ll configure iTerm2 to execute anytime you open a new window.
Setting it up
First off, place the above script in a location that’s accessible to iTerm2 (I usually place it in ~/.dotfiles/tmux.start.sh).
Then open up iTerm2’s terminal preferences and have it execute this script anytime you open a new window:
Usage
Once you’ve done all the above, everytime you open a new window, you’ll be prompted to choose which previous workspace you want to join.
You’ll also have the opportunity to create new work spaces by choosing NEW SESSION. Or if you don’t want to open a full blown tmux session, you can choose to just open up a BASH prompt. All of these sessions are persistent. So if you decide to close your terminal window, they will remain active in the background and ready for you to rejoin at a later point in time.
Discussion