Declare and version control you tmux sessions
Chris Dawkins
Posted on April 16, 2023
Anyone who spends a significant amount of time in the command line understands how tedious and cumbersome managing multiple tmux sessions can be. Many programmers find themselves switching between a variety of projects of different languages and sizes on a daily basis. With tmuxp
you can declare what a tmux session for a project should look like using json/yaml.
A simple declaration that fetches from a remote repo and opens neovim
in one window with bottom
running in a second.
# ~/example/.tmuxp.yaml
session_name: Swoll Sesh
start_directory: ~/example
windows:
- window_name: nvim
panes:
- shell_command:
- git fetch
- nvim .
- window_name: monitor
panes:
- shell_command:
- btm
To start this session just run:
tmuxp load ~/example
This file can then be version controlled, keeping your developer environment organized, consistent and reusable. You can find more examples in the documentation
Combining this with one of the session management plugins for neovim/vim means that your editor will automatically open where you want it.
This can be even further expanded with nix
, flakes
, direnv
, and nix-direnv
to give you a fully automated and reproducible developer environment complete with the environment variables and dependencies needed to start hacking on a project.
Posted on April 16, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.