Eternal Terminal, tmux, iTerm2, and you
C-C-C-Combo!
Prelude: tmux
For the rest of this post to make sense, you ought to have some understanding of tmux. tmux is a terminal multiplexer and session manager, meaning that if you disconnect from your machine you can reattach to your previous session and the state of your terminal tabs (managed within tmux) will be restored as if you had never left. It is a highly recommended tool for remote development. It is often considered a successor to screen.
First there was mosh…
After I finally joined a team at my new job nearly two months past my February start date, my new team mates were quick to inform me that I should ditch my tried-and-true ssh in favor of mosh. What is mosh? Well, it is essentially a drop-in replacement for ssh that is designed for development with spotty connections (hence mobile shell) where your local IP address might even change. It will essentially keep your SSH session alive regardless of your network status, meaning that even if you put your computer to sleep it will reconnect as if you’d never left: when your connection drops the shell will appear to hang, but when it automatically reconnects all recorded output from the remote server will be delivered to your local terminal and all queued input from your terminal will be sent to the server. Slick! This is especially important at my company where development typically takes place on a remote server which additionally requires two-factor authentication (2fa) to get access; with mosh you only have to 2fa when you make the first connection. Coupled with the session management of tmux, you will have a development environment automatically tolerant of any connectivity issues and system sleeping. The only time you need to do anything is when one of the machines is restarted (reinitiate the mosh session, attach/create the tmux session) which, if you’re like me, is quite rare.
Now don’t get me wrong, mosh is great, but it has some shortcomings that had me yearning for something better. With a little Google-fu, I discovered the drop-in-replacement tool I’d been looking for - eternal terminal
…and then there was et
The most important feature et has over mosh is that it supports the tmux control center flag, which you probably (hopefully!) know as tmux -CC. If you don’t know about tmux control center, it allows you to run a tmux session using your local terminal emulator as a controller instead of having to use the shell controls (you’ll never need to type that ctrl+b prefix again!). This means that you get a separate terminal window for your tmux session with tabs, mouse support, resizing, scroll history, searching, etc. With the connection tolerance of et added to the mix, it feels 99% identical to having a local terminal session! Awesome!! Superlative!!! One caveat: iTerm2 is (roughly) the only terminal emulator compatible with tmux control center. Given all the awesome features iTerm2 has though (I love instant-replay), I can’t see a reason to use a different terminal emulator anyway.
Shut up and take my money!
Getting et, tmux, and iTerm2 set up is pretty easy. Follow the et guide and you’ll be up and running in no time. If you enjoy these tools anywhere near as much as I have, please consider donating to these awesome developers (though only the iTerm2 guys readily accept them)! =)
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Email