joebonneau / sesh

Smart session manager for the terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sesh, the smart terminal session manager

tests goreport

BETA: This project is in active development. Please check out the issues and contribute if you're interested in helping out.

How to install

To install sesh, run the following homebrew command:

brew install joshmedeski/sesh/sesh

Using Go

Alternatively, you can install Sesh using Go's go install command:

go install github.com/joshmedeski/sesh@latest

This will download and install the latest version of Sesh. Make sure that your Go environment is properly set up.

Note: Do you want this on another package manager? Create an issue and let me know!

How to use

sesh list will list all your sessions, and sesh connect {session} will connect to a session (automatically creating it if it doesn't exist yet). It is best used by integrating it into your sehll and tmux.

fzf

The easiest way to integrate sesh into your workflow is to use fzf. You can use it to select a session to connect to:

sesh connect $(sesh list | fzf)

tmux + fzf

In order to integrate with tmux, you can add a binding to your tmux config (tmux.conf). For example, the following will bind ctrl-a T to open a fzf prompt as a tmux popup (using fzf-tmux) and using different commands to list sessions (sesh list -t), zoxide directories (sesh list -z), and find directories (fd...).

 bind-key "T" run-shell "sesh connect $(
	sesh list -tz | fzf-tmux -p 55%,60% \
		--no-sort --border-label ' sesh ' --prompt '⚑  ' \
		--header '  ^a all ^t tmux ^x zoxide ^f find' \
		--bind 'tab:down,btab:up' \
		--bind 'ctrl-a:change-prompt(⚑  )+reload(sesh list)' \
		--bind 'ctrl-t:change-prompt(πŸͺŸ  )+reload(sesh list -t)' \
		--bind 'ctrl-x:change-prompt(πŸ“  )+reload(sesh list -z)' \
		--bind 'ctrl-f:change-prompt(πŸ”Ž  )+reload(fd -H -d 2 -t d -E .Trash . ~)'
)"

You can customize this however you want, see man fzf for more info on the different options.

zf

zf is an alternative fuzzy finder designed for filtering filepaths, I've found it to be more accurate than fzf. It doesn't have as many options, but it's still a great tool. You can use it to select a session to connect to:

sesh connect (sesh list | zf --height 24)

Configuration

To configure sesh, you will need to create sesh/sesh.toml with $XDG_CONFIG_HOME or $HOME/.config as the root directory, depending on whether the former has been set. On MacOS, this will likely be ~/.config/ by default and therefore the configuration filepath would be ~/.config/sesh/sesh.toml. See the Go docs for more information.

An example of the sesh.toml file is shown below with all configurable options and their default values:

default_startup_script = "~/git_repos/dotfiles/bin/sesh/default.sh"

[[startup_scripts]]
session_path = "~/git_repos/sesh"
script_path = "~/git_repos/dotfiles/bin/sesh/sesh.sh"

Startup Scripts

Startup scripts will be ignored if the --command/-c flag is passed! Startup scripts will only be run upon session creation!

If a [[startup_scripts]] entry is present for a given session path, then the startup script path specified by script_path will be run when the session is created. Otherwise, if default_startup_script is specified, then the script at that path will be executed. Make sure that the scripts specified are executable, e.g. chmod +x ~/git_repos/dotfiles/bin/sesh/default.sh.

Background (the "t" script)

Sesh is the successor to my popular t-smart-tmux-session-manager tmux plugin. After a year of development and over 250 stars, it's clear that people enjoy the idea of a smart session manager. However, I've always felt that the tmux plugin was a bit of a hack. It's a bash script that runs in the background and parses the output of tmux commands. It works, but it's not ideal and isn't flexible enough to support other terminal multiplexers.

I've decided to start over and build a session manager from the ground up. This time, I'm using a language that's more suited for the task: Go. Go is a compiled language that's fast, statically typed, and has a great standard library. It's perfect for a project like this. I've also decided to make this session manager multiplexer agnostic. It will be able to work with any terminal multiplexer, including tmux, zellij, Wezterm, and more.

The first step is to build a CLI that can interact with tmux and be a drop-in replacement for my previous tmux plugin. Once that's complete, I'll extend it to support other terminal multiplexers.

Contributors

Made with contrib.rocks.

About

Smart session manager for the terminal

License:MIT License


Languages

Language:Go 100.0%