Tmuxifier — One Up Your Tmux Game

Adam Drake
4 min readApr 15, 2024

--

AI generated… by little monkeys

I have discovered a powerful little tool to aid me in my quest to fully grasp the benefits of the Tmux world. I discovered it through Typecraft in one of his excellent Youtube videos. It’s a tool that helps you open a dev environment for any project in Tmux with all the right windows ready so you can get cracking on those code tweaks as soon as possible. It’s also been around for a while so has stood the test of time (which is saying something in this day and age!).

What Does Tmuxifier do?

According to the Tmuxifier Github page, Tmuxifier helps you Create, edit, manage and load complex Tmux session, window and pane configurations with ease.

This basically means if you have one Tmux window open where is your terminal, another Tmux window open which are you tests and another Tmux window which is your editor and all of these are for a specific project you can create a Tmuxifier window layout to define these. With one command in the terminal you can be up and running and get cracking on your work.

This might be clearer with an actual example…

Tmuxifier — Getting Setup

Before using Tmuxifier you do need to git clone it onto your computer.

git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier

You also need Tmux. (If you don’t know what Tmux is then check out my other post about Tmux). On the Tmuxifier Github page, there are pretty clear instructions about how to install it and get it up and running. Make sure you follow all the instructions as it’s not just a case of git clone and thats it. You also have to update your .zshrc file.

Basic Example

In Tmuxifier you can basically create and edit Window Layouts or Session Layouts. The meaning of Window and Session here are the same as the Tmux definitions.

I created a Session Layout for my blog that I develop locally on my computer. I was feeling particularly creative that day so I called it blog. To create this Session Layout I ran the following command:

tmuxifier new-session blog

This created a bash file blog.session.sh in which you can write the script for setting up your session. What I have set up is very basic for my blog as it’s a simple application but hopefully it will give you an idea and inspiration to get started:

# Set a custom session root path. Default is `$HOME`.
# Must be called before `initialize_session`.
session_root "~/Documents/personal"

# Create session with specified name if it does not already exist. If no
# argument is given, session name will be based on layout file name.
if initialize_session "blog"; then

# Create a new window inline within session layout definition.
new_window "frontend"
new_window "backend"

# Select the default active window on session creation.
select_window "frontend"
run_cmd "cd adamdrake-site-blog"
run_cmd "npx yarn dev"

select_window "backend"
run_cmd "cd adamdrake-sanity-blog"
run_cmd "pnpm dev"

select_window "frontend"

fi

# Finalize session creation and switch/attach to it.
finalize_and_go_to_session

So what’s going on here:

  • seesion_root — This sets the root directory for your session.
  • if initialize_session "blog"; then — This is part of the boiler plate code when you create a new Session Layout but it’s basically initialising the session with the given name.
  • new_window — This creates a new tmux window in this session and gives it the name provided in the double quotes.
  • select_window — Selects the window provided in the double quotes. If the name in the quotes doesn’t exist it throws an error.
  • run_cmd — Runs the command provided in the quotes.

Honestly, it’s all pretty straightforward and easy to get going with this. In this particular instance I am just opening two windows in Tmux and getting my frontend and backend code bases running for my blog.

Common Commands

I’ve been using Tmuxifier for a few weeks now and these are the most common commands I am using:

# Long
tmuxifier edit-session blog

# Short
tmuxifier es blog

This command allows you to edit the Session Layout you created.

# Long
tmuxifier load-session blog

# Short
tmuxifier s blog

This command allows you to actually load the Session Layout you created.

tmuxifier new-session <seesion-name-goes-here>

This allows you to create a new Session Layout.

Conclusion

Is this tool going to totally change your life? Probably not. But it will help you get up and running on projects that you are consistently working on. Half the battle sometimes can just be getting up and running so by running one command to be able to get going is a win.

Plus I have found I now keep my desktop more tidy. I used to leave my terminal windows open at the end of the day so I didn’t have to set up everything the next day. Now I can quite happily close everything when I have finished working on a project knowing I can come back the next day and get my setup up and running quickly.

About me

I am a Frontend Developer working mainly with React and Typescript in my day-to-day professional life. I love exploring new tools and libraries and love the Javascript Ecosystem.

I like to write blog posts that share exciting new tools I’ve discovered, how-to articles, and also the occasional opinion piece.

I live in Prague in the Czech Republic with my family.

Check out the original blog post on my blog.

Check out my LinkedIn and Github if you are interested.

--

--

Adam Drake

I'm a Frontend Developer and I write about all things Frontend Related - Think lightly of yourself and deeply of the world. Based in Prague, CZ