Tmux Dev Env Setup Speedup

Tmux can help you set up your development environment more quickly.

Many Tool Options

There are many tools used to make development environments work better or faster. For example, containerization with docker and docker-compose. I don't love these tools because of the cost of the abstraction: getting the image configuration write and waiting for containers to build.

Without containers, whoever, I'm left with a bunch of terminals open, each running some process required for the software I'm writing, that's commonly distributed over n processes.

Tmux Helps

The terminals don't bother me. But I'm grateful to have a tool like tmux to help manage the windows. Tmux is a terminal multiplexer, so it can show many different programs in a single terminal.

Scripting Tmux

Even better, you can script tmux to open certain windows and run certain commands within them. For a small example, consider the following development environment:

  • Window 1: Editor for coding

  • Window 2: Split panes for 2 processes: one for the frontend process, one for the backend

An env.sh script might be devised like:

cd ~/dev/proj

EDIT_SESSION="proj"
tmux new-session -d -s $EDIT_SESSION

# editing
tmux new-window -t $EDIT_SESSION:1 -n "edit"
tmux send-keys "nvim ." C-m

# processes
tmux new-window -t $EDIT_SESSION:2 -n "proc"
tmux select-window -t $EDIT_SESSION:2
tmux send-keys "cd client && npm start" C-m
tmux split-window -v -t 2 
tmux send-keys "cd server && clj -M:server" C-m

tmux attach -t $EDIT_SESSION

Pretty neat! And you can imagine how this script might be expanded upon. What are some ways you manage your development environment for speed setup?