Terminal Setup: Beyond the multiplexer with Sesh-

In my previous , I shared concisely how my terminal dev environment look like with kitty, tmux and nvim. Let's talk about how I use tmux with sesh to speed up productivity.

Sesh?

Sesh is smart session manager for tmux, it's a useful tool that combines zoxide and tmux sessions.

For installation, follow the .

After that, integrate with tmux by adding this to .tmux.config

bind-key "S" run-shell "sesh connect \"$(  sesh list --icons | fzf-tmux -p 80%,70% \    --no-sort --ansi --border-label ' sesh ' --prompt '⚡  ' \    --header '  ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \    --bind 'tab:down,btab:up' \    --bind 'ctrl-a:change-prompt(⚡  )+reload(sesh list --icons)' \    --bind 'ctrl-t:change-prompt(🪟  )+reload(sesh list -t --icons)' \    --bind 'ctrl-g:change-prompt(⚙️  )+reload(sesh list -c --icons)' \    --bind 'ctrl-x:change-prompt(📁  )+reload(sesh list -z --icons)' \    --bind 'ctrl-f:change-prompt(🔎  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \    --bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡  )+reload(sesh list --icons)' \    --preview-window 'right:55%' \    --preview 'sesh preview {}')\""

You can bind any key that make sense to you, I choose S (S == Sesh).

It will open a popup running sesh with prefix + S

But to open that we need to be in a tmux session, it’s more convenient if we can open that in terminal without any active tmux session.
We can run this command below in terminal directly

sesh connect "$(  sesh list --icons --hide-duplicates | fzf --no-border \    --ansi \    --list-border \    --no-sort --prompt '⚡  ' \    --color 'list-border:6,input-border:3,preview-border:4,header-bg:-1,header-border:6' \    --input-border \    --header-border \    --bind 'tab:down,btab:up' \    --bind 'ctrl-a:change-prompt(⚡  )+reload(sesh list --icons)' \    --bind 'ctrl-t:change-prompt(🪟  )+reload(sesh list -t --icons)' \    --bind 'ctrl-g:change-prompt(⚙️  )+reload(sesh list -c --icons)' \    --bind 'ctrl-x:change-prompt(📁  )+reload(sesh list -z --icons)' \      --bind 'ctrl-f:change-prompt(🔎  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \    --bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡  )+reload(sesh list --icons)' \    --preview-window 'right:70%' \    --preview 'sesh preview {}' \)"

Or we can save that command to a script file (e.g. sesh_start), add that to your $PATH so we can run it anywhere.

Now we can open the sesh popup by running sesh_start script in terminal, then we can open a tmux session.

Sesh custom configs

Sesh allows you to define how specific sessions should behave. For example, if I open a project, I usually want Nvim to start automatically.
That could be done by using sesh config file, create sesh.toml file in $HOME/.config/sesh

[[session]]name = "Personal Blog"path = "~/dev/blog"startup_command = "nvim ."

Or you can use startup command with a script path to do something like this

[[session]]name = "Personal Blog"path = "~/dev/blog"startup_command = "~/.config/sesh/scripts/blog_dev"

the script:

#!/usr/bin/env fish# Get the ID of the original windowset original_window (tmux display-message -p '#{window_id}')# Create a new tmux window for bun run devtmux new-window -n "bun-dev" "bun run dev; read"# Switch back to the original windowtmux select-window -t $original_window# Open nvim with Telescope in the original windowtmux send-keys -t . "nvim" Enter ":Telescope find_files" Enter

it will create a tmux session with two windows, one for nvim and the other (bun-dev) running dev server.

Keybinding (kitty)

Tmux default prefix is C-b (ctrl + b), tapping too many keys to open sesh is a bit annoying, with above config, I have to hit ctrl + b -> shift + s.

I'm using Kitty and I will remap tmux prefix with super key. In order to find out what exactly Kitty send to terminal for keystrokes, run this in your Kitty

kitty +kitten show_key

the output for tmux prefix C-b is \x02, so C-b S will be \x02S, add that to kitty.conf

#: remap to use super (cmd, command, ⌘) instead of prefix for tmux# default tmux prefix: C-b is \x02# open sesh popupmap super+s send_text all \x02S

Now, I can hit super+s to open sesh popup.
Below is more tmux keybindings I've set up in my Kitty:

map super+t send_text all \x02c # create new tmux windowmap super+w send_text all \x02x # close current tmux windowmap super+n send_text all \x13n # next tmux window

Conclusion

Hope this could help, here is my .

Leave comment

On this page