Interactive Development with Tmux + GHCi

For rapid iteration with long-running REPL sessions:

# Start tmux session with better defaults (wider, taller, larger scrollback)
tmux new-session -d -s project-repl -x 120 -y 50
tmux set-option -t project-repl history-limit 10000
tmux send-keys -t project-repl "cabal repl <package>" Enter

# NEVER use sleep! Capture large context instead
tmux capture-pane -t project-repl -S -200 -p

# Send commands to REPL
tmux send-keys -t project-repl "COMMAND_HERE" Enter

# Always capture large context for debugging
tmux capture-pane -t project-repl -S -200 -p

# For really long outputs or complete session history
tmux capture-pane -t project-repl -S - -p

# Reload after file changes
tmux send-keys -t project-repl ":reload" Enter

# Kill session when done
tmux kill-session -t project-repl

Tmux Capture Best Practices

Always use large context capture to see full execution flow:

# Default: Capture last 200 lines (shows context and results)
tmux capture-pane -t session -S -200 -p

# For complete session history (debugging complex issues)  
tmux capture-pane -t session -S - -p

# Only use small context for quick status checks
tmux capture-pane -t session -S -10 -p

# Save output to file for analysis
tmux capture-pane -t session -S -200 -p > debug-output.txt

# Resize existing session if output is truncated
tmux resize-window -t session -x 120 -y 50

Multi-line Input with tmux send-keys

When sending multi-line inputs to a tmux pane, use the following strategies:

# Option 1: Escape newlines with quotes
tmux send-keys -t project-repl "long command with \
multiple lines \
and continuation" Enter

# Option 2: Use single quoted string
tmux send-keys -t project-repl '
multiline
input
goes here
' Enter

Anti-Pattern: NEVER use sleep commands - they slow down development and don't guarantee operations complete. Use large context capture instead.