Increased Developer Productivity with Tmux, Part 4: Starter templates

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

Creating a Tmux Starter Template

In Part 3 I covered Tmux session management. In this installment, I instruct on how to created your own Tmux starter templates. As you start relying on Tmux as a development tool you are going to find yourself going through many of the same motions when applying it to a project. For example, you always use the first window for Vim with a right pane for running specs, so you run the commands for splitting the first window into 2 vertical panes, labeled "Vim", and you resize the left pane to be wider because you want to prevent word wrapping. Next, Git always used for window 2 so you go through a series of similar commands. Next, the same tedious process is repeated for window 3 and so on and so on. Let's explore how to automate this with a starter Tmux template.

Minimul says —

The starter template I discuss in this article and screencast can be found here. In addition, I use one other template for Rails projects.

I am going to go over my general purpose starter template, ~/.tmuxgo.

A bash script that opens 5 Tmux windows that I commonly need across all of my projects.

Windows 3 & 4 are similar to the other 2 windows but the 5th window introduces running a shell command.

Simply have the shell command as the last part of the new-window command.Elinks is ready for duty.

The last two commands: (1) make sure that the first window is selected upon launch; and (2) reattaches the detached session.

Final commands explained.

That concludes installment 4. Tmux Starter Templates

Once you start investing in Tmux as a development tool you will quickly tire of having to setup your basic windows, panes, pane sizing, and executing routine commands for every project. In the article and screencast I instruct on how to automate this pain point with an uncomplicated bash script.

I'd also make you aware of Tmuxinator, which also seeks to address this challenge. I have not used the tool as the approach taught in this article has satisfied my needs, therefore, you also may want to start with this method. Next in part 5, I address the powerful send-keys command. While you are waiting for the article check out the screencast that is already baked.