Tmux sessionizing

2026–05–20

Backing motivation

Link to all code

Video demo

I’ve always used a ton of bash scripts for my main work flows. From generating homework templates from my LaTeX days to parsing webpages to form my local homework due deadline calenders. But recently as my Inpirion has begun dying a slow and painful death after 3 years of use, new problems have emerged.

With the occasional random poweroffs and inability to sleep without fully shutting off, I’m not longer able to just leave each of my projects open on a different i3 tags. So I’ve begun exploring an old rite of passage for tiling window manager using vimmers, TMUX

My main desire for TMUX comes from it’s ability to maintain and hold sessions in a small format that can be accessed later (using a script). These persistent sessions are useful for a few reasons :

So how do we go about this? The most famous starting point for a sessionizing script would be the well known Primeagain script. But this script has a few problems in my opinion,

So here I can introduced an improved sessionizing script that fulfills the original goals of the primeagen’s script while being just slightly longer.

Here you have a few options and improvements :

Visual Walk Through

So let’s see some of this, here you’ll see how I edit the website from my terminal. This is a persistent session that runs constantly on my laptop and allows me to constantly locally build and iterate on the blog.

When using my spits, I generally have one pane that runs / monitors the server I’m working on, In this instance the localhost serving the site, and a second that controls my version control in the lower right.Then neovim / my text editor runs on the main pane in the middle. Many people have told me that this is suboptimal.

So here’s the visual of the splits : Image of TMUX Splits

Then we cover the wonderful sessionizing script linked at the top of the article. Essentially it requires you declare a few directories you have interest in as well as a default directory you’d like new repos / sessions to be declared in. In my case, it’s $HOME/dev/ for reusability and portability.

The script presumes that in each directory under your dev, you have one project that will contain one session. If there’s already a session , it’ll attach to the old one, and if there isn’t it’ll initialize one at the project’s root. You’re also able to call from within sessions to other sessions and it’ll handle detaching before attaching very elegantly.

Here’s an image of the script being called as a tmux-popup : Image

The script is also able to add new local directories and sessions. But it most notably has the ability to pull from github / codeberg and clone locally. But that write up must be done later!