Member-only story
How to Use tmuxp to Manage Your tmux Session
Take control of your tmux sessions
As a programmer, pretty much every workday starts by setting up my dev environment for the specific task I’m working on.
During this time, I will spend a couple of minutes setting up my tmux windows and panes, and every time, I say to myself that there is no need to have something automated since it does not take too much time. However, it becomes grueling when I switch back and forward between tasks requiring different layouts.
At first, I tried using some basic scripts but shortly failed to maintain them since it took considerable effort to update. Then, I found tmuxp. I have been using it for some time now, and I’m ready to share my experience.
So if you are like me and you like having a specific layout for every task, and you want to spend the least amount of time managing the configurations, then this post is definitely for you.
Setup
First, make sure that you have tmux 1.8 or above and python 2.6 or above installed. Then, install tmuxp using the following:
# For macOs
$ brew install tmuxp# Using pip (python package manager)
$ pip install --user tmuxp
Once installed, you need to set the following environment variable in your rc file (.i.e .zshrc
).
export DISABLE_AUTO_TITLE='true'
The Basics
Storing the Configurations
Tmuxp configurations are either YAML or JSON files, and you need to decide where you want to store them. You can keep the configuration files:
- Somewhere in your file system.
- In your project directory as
.tmuxp.yaml
or.tmuxp.json
. - In your
XDG_CONFIG_HOME
($HOME/.config/tmuxp
). - In
$HOME/.tmuxp
. - In a custom path referenced by the
TMUXP_CONFIGDIR
environment variable.
All these methods will have the same result (starting tmux with the desired config). However, with one of the last three options, you can start your tmux session from anywhere in your file system and without typing the path of the…