Skip to content

Workflow 002: Multi-Project Setup

Fresh

Manage multiple projects simultaneously using tmux sessions and windows.

When to Use

  • Working on multiple projects daily
  • Need quick context switching
  • Want isolated environments per project
  • Managing microservices or monorepos

Strategy Overview

Setup

Project Session Script

Create ~/bin/proj (make executable with chmod +x):

bash
#!/bin/bash
# Usage: proj <project-name> [project-path]

PROJECT=$1
PROJECT_PATH=${2:-"$HOME/projects/$PROJECT"}

if [ -z "$PROJECT" ]; then
    echo "Usage: proj <project-name> [project-path]"
    exit 1
fi

# Check if session exists
tmux has-session -t "$PROJECT" 2>/dev/null

if [ $? != 0 ]; then
    # Create new session
    tmux new-session -d -s "$PROJECT" -n editor -c "$PROJECT_PATH"

    # Editor window (already created)
    tmux send-keys -t "$PROJECT:editor" 'vim .' C-m

    # Server window
    tmux new-window -t "$PROJECT" -n server -c "$PROJECT_PATH"

    # Tests window
    tmux new-window -t "$PROJECT" -n tests -c "$PROJECT_PATH"

    # Git window
    tmux new-window -t "$PROJECT" -n git -c "$PROJECT_PATH"
    tmux send-keys -t "$PROJECT:git" 'git status' C-m

    # Select editor window
    tmux select-window -t "$PROJECT:editor"
fi

# Attach to session
tmux attach -t "$PROJECT"

Framework-Specific Setups

Node.js Project

bash
#!/bin/bash
PROJECT="myapp"
PROJECT_PATH="$HOME/projects/$PROJECT"

tmux new-session -d -s "$PROJECT" -n code -c "$PROJECT_PATH"

# Code window with split
tmux send-keys -t "$PROJECT:code" 'vim .' C-m
tmux split-window -h -t "$PROJECT:code" -c "$PROJECT_PATH"
tmux send-keys -t "$PROJECT:code.1" 'npm run dev' C-m

# Tests window
tmux new-window -t "$PROJECT" -n tests -c "$PROJECT_PATH"
tmux send-keys -t "$PROJECT:tests" 'npm test -- --watch' C-m

# Logs window
tmux new-window -t "$PROJECT" -n logs -c "$PROJECT_PATH"

tmux select-window -t "$PROJECT:code"
tmux attach -t "$PROJECT"

Python Project

bash
#!/bin/bash
PROJECT="pyapp"
PROJECT_PATH="$HOME/projects/$PROJECT"
VENV_PATH="$PROJECT_PATH/venv"

tmux new-session -d -s "$PROJECT" -n code -c "$PROJECT_PATH"

# Activate venv in all windows
ACTIVATE="source $VENV_PATH/bin/activate"

# Code window
tmux send-keys -t "$PROJECT:code" "$ACTIVATE && vim ." C-m

# Server window
tmux new-window -t "$PROJECT" -n server -c "$PROJECT_PATH"
tmux send-keys -t "$PROJECT:server" "$ACTIVATE && python manage.py runserver" C-m

# Shell window
tmux new-window -t "$PROJECT" -n shell -c "$PROJECT_PATH"
tmux send-keys -t "$PROJECT:shell" "$ACTIVATE" C-m

# Tests
tmux new-window -t "$PROJECT" -n tests -c "$PROJECT_PATH"
tmux send-keys -t "$PROJECT:tests" "$ACTIVATE && pytest --watch" C-m

tmux select-window -t "$PROJECT:code"
tmux attach -t "$PROJECT"

Daily Workflow

Start of Day

bash
# Open all project sessions
proj frontend ~/code/frontend
# Detach: Ctrl+b d

proj backend ~/code/backend
# Detach: Ctrl+b d

proj devops ~/code/infra
# Stay attached or detach

Switching Projects

bash
# From within tmux, show session list
Ctrl+b s

# Navigate with arrows, Enter to switch
# Or use shortcuts:
Ctrl+b (    # Previous session
Ctrl+b )    # Next session

Context-Aware Windows

Navigate windows:

bash
Ctrl+b w    # Window list across all sessions
Ctrl+b n    # Next window in session
Ctrl+b p    # Previous window
Ctrl+b 1-9  # Jump to window number

Microservices Layout

For microservices, use one session with service-per-window:

bash
#!/bin/bash
SESSION="microservices"
BASE="$HOME/projects/microservices"

tmux new-session -d -s $SESSION -n overview

# Service windows
for service in auth users orders payments notifications; do
    tmux new-window -t $SESSION -n $service -c "$BASE/$service"
    tmux send-keys -t "$SESSION:$service" "docker-compose up" C-m
done

# Monitoring window
tmux new-window -t $SESSION -n monitor
tmux send-keys -t "$SESSION:monitor" "docker ps --format 'table {{.Names}}\t{{.Status}}' -a" C-m

tmux select-window -t $SESSION:overview
tmux attach -t $SESSION

Monorepo Layout

bash
#!/bin/bash
SESSION="monorepo"
BASE="$HOME/projects/monorepo"

tmux new-session -d -s $SESSION -n root -c "$BASE"

# Package windows
tmux new-window -t $SESSION -n web -c "$BASE/packages/web"
tmux new-window -t $SESSION -n api -c "$BASE/packages/api"
tmux new-window -t $SESSION -n shared -c "$BASE/packages/shared"

# Development window with all services
tmux new-window -t $SESSION -n dev -c "$BASE"
tmux send-keys -t "$SESSION:dev" "npm run dev" C-m

tmux select-window -t $SESSION:root
tmux attach -t $SESSION

Session Management Commands

bash
# List all sessions
tmux ls

# Kill specific session
tmux kill-session -t frontend

# Kill all sessions except current
tmux kill-session -a

# Rename session
Ctrl+b $

# Create new session from within tmux
:new -s newproject

Tips

Quick Session Aliases

Add to ~/.bashrc or ~/.zshrc:

bash
alias pf='proj frontend'
alias pb='proj backend'
alias pd='proj devops'
alias tls='tmux ls'
alias ta='tmux attach -t'

Session Naming Convention

Use consistent naming:

  • project-name for main work
  • project-name-feature for feature branches
  • scratch for temporary work

Window Naming Convention

Consistent window names across projects:

  1. editor - Main code editing
  2. server - Running dev server
  3. tests - Test runner
  4. git - Version control
  5. shell - General terminal

Troubleshooting

Too many sessions

bash
# List and review
tmux ls

# Kill unused ones
tmux kill-session -t old-project

Forgot which session has what

bash
# Preview sessions and windows
Ctrl+b s    # Expand with arrow keys

Need to move window between sessions

bash
:move-window -s source-session:window -t target-session:

See Also

Generated with AI-powered SOP Generator