Max SchmittMS
20th October 2020

How to speed up your development workflow with tmux scripts

I have a few long-living projects that I work on multiple times a week. For each one of these, I need to usually navigate to a certain directory and start up one more development-servers.

For example, for my day job at Wunderflats, I'll be spinning up two backend applications and two frontend applications almost every day.

It doesn't take long but it's just a tiny bit of friction that can be annoying, especially when I just want to try out something real quick.

Starting my dev servers with a single command

To make my life a little bit easier, I wrote a little tmux script that I've added to my PATH as wflats-dev.

It enables me to do this:

Here is the script line by line:

~/bin/wflats-dev

#!/usr/bin/env bash
# Use Node.js version 10
n 10
# Create a new tmux session in the background called "wflats"
tmux new -s wflats -d
# Navigate to api
tmux send-keys "cd ~/wunderflats/code/api/packages/api" C-m
# Run `yarn dev`
tmux send-keys "yarn dev" C-m
# Split the window vertically and navigate to website
tmux split-window -c ~/wunderflats/code/website -v
# Run `yarn dev`
tmux send-keys "yarn dev" C-m
# Split the window horizontally and navigate to landlord-dashboard
tmux split-window -c ~/wunderflats/code/landlord-dashboard -h
# Select the top pane
tmux select-pane -U
# Split the window horizontally and navigate to landlord-dashboard
tmux split-window -c ~/wunderflats/code/landlord-dashboard -h
# Run `yarn dev`
tmux send-keys "yarn dev" C-m
# Select the pane on the left
tmux select-pane -L
# Split the window vertically and navigate to image-service
tmux split-window -c ~/wunderflats/code/jobs/packages/image-service -v
# Run `yarn dev`
tmux send-keys "yarn dev" C-m
# Select the bottom-right pane
tmux select-pane -D
tmux select-pane -R
# Go into the tmux session
tmux a -t wflats

After using these scripts for a while, it started irritating me that stopping the entire project had me jumping from pane to pane killing all the processes. Luckily, I found a way to kill the entire tmux session with a keyboard shortcut.

Image of my head

About the author

Hi, I’m Max! I'm a fullstack JavaScript developer living in Berlin.

When I’m not working on one of my personal projects, writing blog posts or making YouTube videos, I help my clients bring their ideas to life as a freelance web developer.

If you need help on a project, please reach out and let's work together.

To stay updated with new blog posts, follow me on Twitter or subscribe to my RSS feed.