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.
To make my life a little bit easier, I wrote a little tmux script that I've added to my
It enables me to do this:
Here is the script line by line:
~/bin/wflats-dev#!/usr/bin/env bash# Use Node.js version 10n 10# Create a new tmux session in the background called "wflats"tmux new -s wflats -d# Navigate to apitmux 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 websitetmux 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-dashboardtmux split-window -c ~/wunderflats/code/landlord-dashboard -h# Select the top panetmux select-pane -U# Split the window horizontally and navigate to landlord-dashboardtmux split-window -c ~/wunderflats/code/landlord-dashboard -h# Run `yarn dev`tmux send-keys "yarn dev" C-m# Select the pane on the lefttmux select-pane -L# Split the window vertically and navigate to image-servicetmux split-window -c ~/wunderflats/code/jobs/packages/image-service -v# Run `yarn dev`tmux send-keys "yarn dev" C-m# Select the bottom-right panetmux select-pane -Dtmux select-pane -R# Go into the tmux sessiontmux 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.
If you need help on a project, feel free to contact me.