Juggling Projects in my Terminal
As a consultant and hobbyist programmer, I'm often jumping between projects. Tmux makes it easy to do this in my terminal without losing my sanity.
by Mario ·
What is Tmux?
A server which stores and serves the state of multiple terminal sessions.
You can leave a session running in the background and the server will keep it alive and manage its state.
Each session can have multiple windows/panes/programs running.
A client which lets you access a terminal session which is being managed by the tmux server.
You can create new windows/panes in existing sessions.
You can detach your terminal from the tmux server, without losing the state of the programs running in other sessions.
This makes it super useful for working on multiple projects, without losing the state of your terminal sessions as you switch between them. You can leave your dev servers running 24/7.
This works even better if you use a terminal-based editor - neovim is my poison, but tmux will happily keep your nano and helix instances alive as you jump between projects.
How I use it
ctrl-b ctrl-jlet's me fuzzy find between sessionsctrl-b 1-9to switch between windows in the current sessionI rarely use split panes
I usually have neovim running on window 1, shell (for dev server etc) on 2, clanker on 3
ctrl-b ctrl-sto save my tmux sessions before I restart my laptopctrl-b ctrl-rto reload my tmux session after I restart my laptoptmux-sessionscript to start new tmux sessions
My Setup
I try to keep my setup minimal, but have landed on the following plugins to help with my workflow:
Alex Six's tmux starter config copied to
~/.tmux.conftmux-sessionizer(Github) for quickly switching between active sessionstmux-continuum(Github) for continuously saving my tmux environment and automatically restarting the tmux server when I restart my laptoppowered by
tmux-resurrect(Github) for the environment saving
I also have a tmux-session.sh script in my path for quickly creating new sessions. It'll launch nvim, a shell and Claude in the current directory, or attach to an existing session if it finds one
#!/bin/bash
# Argument validation check
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <session-name>"
exit 1
fi
SESSION_NAME=$1
CURRENT_DIR=$PWD
# Exit if tmux session already exists
tmux has-session -t $SESSION_NAME 2>/dev/null
if [ $? -eq 0 ]; then
echo "Session already exists. Attaching..."
tmux attach -t $SESSION_NAME
exit 0
fi
# Create a new detached session
tmux new-session -d -s $SESSION_NAME -n "code"
tmux send-keys -t $SESSION_NAME:1 "cd $CURRENT_DIR" C-m
tmux send-keys -t $SESSION_NAME:1 "nvim ." C-m
# Create shell window
tmux new-window -t $SESSION_NAME:2 -n "shell"
tmux send-keys -t $SESSION_NAME:2 "cd $CURRENT_DIR" C-m
# Create clanker window
tmux new-window -t $SESSION_NAME:2 -n "clanker"
tmux send-keys -t $SESSION_NAME:2 "cd $CURRENT_DIR" C-m
tmux send-keys -t $SESSION_NAME:1 "claude" C-m
# Select the first window and attach
tmux select-window -t $SESSION_NAME:1
tmux attach-session -t $SESSION_NAME