Smart tmux sessions with sesh
The way I use Tmux has changed a lot in the last year, so let’s talk about it.
Intro
I rewrote my tmux plugin called ‘t’ in early 2024 into a new cli called sesh, written in Go. It offers more features and performance boosts compared to the original bash version.
Here’s the video that started it all, breaking down the idea of combining zoxide and fzf for a more efficient workflow:
How to install
Instead of using tpm to install it as a tmux plugin, sesh is a binary that you install on your machine using Homebrew or Nix.
Run the following command to install it via homebrew:
Other installation methods are available on the sesh GitHub page.
How it works
Sesh combines zoxide and tmux sessions to create a powerful and efficient workflow. The two main commands are sesh list
to list zoxide records, custom config records, and running tmux Sessions, and sesh connect
to connect to a directory and create a Tmux Session.
My YouTuber friend, Dreams of Autonomy, has a great video explaining how zoxide works.
Getting Started
Using sesh connect
with sesh list
and tools like fzf or gum allows for quick selection and creation of Tmux Sessions based on the chosen project or directory.
I prefer gum as I find it faster and prettier.
Startup
Creating custom Tmux Bindings like K
displays a pop-up to switch between or create new tmux Sessions on the fly using a keybinding, similar to command palettes in Discord and GitHub.
If you want a more complex setup, you can use fzf to add keybindings to filter by category or even take actions like kill tmux sessions from within the popup.
macOS keybinding
Binding Sesh to a macOS keybinding like command+K
creates a command bar to move between Sessions quickly and easily.
Naming Sessions
Sesh uses the folder name as the session name by default, but can create more contextualized session names based on the directory structure or git work trees.
For example, the ~/c/Downloads
directory can be named Downloads
in Tmux, while the ~/c/github.com/joshmedeski/sesh
directory can be named sesh
in Tmux.
In a git repository like ~/c/joshmedeski.com/src/content
, sesh will automatically detect the root of the git repository and name the tmux session joshmedeski_com/src/content
.
If you’re working with git worktrees, sesh will use the root of the worktree on the session name. So if I’m working with the directory ~/c/sesh/v2
where v2
is a worktree, the session name will be sesh/v2
, making it easy to contextualize all sesh wokrtrees in your workflow.
Custom configs
Custom configurations can be created using a toml file in the ~/.config/sesh
directory. Sessions can be defined with a location, name, startup command, and startup script to automate actions like opening a file picker or starting a website.
The script is a executable bash file with some simple tmux commands.
You can also import other toml files if you want to break up your configs.
Default Startup
Setting a default startup command like opening NeoVim with a file picker allows for quick access to recently used files whenever switching between sessions and projects for all your projects that don’t have a custom configuration.
Raycast
The sesh companion extension for Raycast makes it easy to use sesh outside of the terminal.
Here are limitations to keep in mind:
- tmux has to be running before you can use the extension
- The extension caches results for a few seconds, so it may not always be up to date
Adding to Zoxide
To make Sesh more useful, it’s important to add records to Zoxide. This can be done by cd
ing into directories or using a shortcut like zad
to list and add multiple directories at once.
Wrapping Up
Sesh is a powerful tool that combines zoxide and tmux sessions to create a more efficient workflow. It allows for quick selection and creation of tmux sessions based on the chosen project or directory, and can be customized with custom configurations and startup scripts to automate actions.
Please give it a star and share it with your friends if you find it useful!
Smart session manager for the terminal
Sign-Up for New Posts
Stay in the loop and get the latest blog posts about dotfiles sent to your inbox.
Or use the