Skip to content

AdamGaskins/tmux-sprout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tmux Sprout

A simple cli app that makes it a breeze to switch between your projects in tmux. (Inspired by Primeagen's tmux-sessionizer)

At the push of a button, swap between all your projects. If a project isn't already open in tmux, a new session is created and your workspace is set up just to your liking based on an insanely simple config file. e.g. When I'm doing web dev, I often have a window for my code editor, a window for my watch script, and a window for shell commands.

In tmux terms, tmux-sprout can quickly switch between tmux sessions, as well as create and hydrate them.

How it works

When you call tmux-sprout [path], a tmux session will be opened to the specified path. If the session exists it will be opened. If not, it will be created.

When a session is created, it checks to see if the path is in the config file. If a match is found, those settings will be used to open all your windows and applications.

For example, when doing web dev, I often have a window for neovim, a window to run my watch rebuild script, and a window for running shell commands.

Installation

Homebrew is the recommended install method:

brew tap adamgaskins/tmux-sprout https://github.com/AdamGaskins/tmux-sprout
brew trust --formula adamgaskins/tmux-sprout/tmux-sprout
brew install tmux-sprout
tmux-sprout --version

You're also welcome to install manually. It is a single binary. Unzip and copy to your bin folder:

cp tmux-sprout /usr/local/bin/tmux-sprout

Using with tmux-sessionizer

Create this script at ~/bin/tmux-sessionizer which allows you to choose a project with fzf:

selected=$(find ~/path1 ~/path2/path3 -mindepth 1 -maxdepth 1 -type d | fzf)

tmux-sprout "$selected"

Then trigger the script wherever you want to switch sessions from. I have it in my zsh and neovim:

# .zshrc
tmux_sessionizer() {
    BUFFER="tmux-sessionizer"
    zle accept-line
}
zle -N tmux_sessionizer
bindkey '^f' tmux_sessionizer # Ctrl + f to switch sessions
-- keymaps.lua

-- Ctrl + f to switch tmux sessions
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")

Installation

Tested on macOS. Probably works on Linux.

Install:

git clone https://github.com/AdamGaskins/tmux-sprout.git tmux-sprout
cd tmux-sprout
go install

Configuration Example

Configuration is read from:

  • tmux-sprout.toml
  • $XDG_CONFIG_DIR\tmux-sprout.toml
  • $HOME\tmux-sprout.toml
# Create a new entry in the projects array for each project

[[projects]]
name = "tmux-sprout"                    # The name of the tmux session
folder = "/Users/adam/lang/my-project"  # The full path to the folder
windows = [
    { name = "shell" },                 # Opens a window (tmux tab) named "shell"
]

[[projects]]
name = "Dotfiles"
folder = "/Users/adam/.dotfiles"
windows = [
    { name = "editor", cmd = "nvim ." }, # Opens neovim in a window named "editor"
    { name = "shell" },
]

# You can also specify partial paths for "folder".
# This will match any folder named "web-project" inside another folder named "lang".
[[projects]]
name = "Web Project"
folder = "lang/web-project"
windows = [
    { name = "editor", cmd = "nvim ." },
    { name = "build", cmd = "npm run dev" },
    { name = "shell" },
]

About

A simple cli to hydrate your tmux sessions.

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages