Skip to content

Tmux Sessionizer: Bash script for creating/switching between tmux sessions using fzf

License

Notifications You must be signed in to change notification settings

mnjm/tmux-sessionizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

tmux-sessionizer

TMUX Sessionizer is a fzf-based tmux session and project switcher written in Bash.

Demo.gif

This is heavily based upon ThePrimeagen's tmux-sessionizer which I found a little non flexible.

  1. Sometimes, I open Tmux sessions for general use outside of specific projects and wanted a script that lists these one-off sessions alongside projects.
  2. My projects organization is somewhat disorganized, as I use entirely different directory structures for my work and personal projects.
  3. I've integrated git worktree into my projects, so was looking for a script that can handle such worktree branchs as well.

How does this tmux-sessionizer work?

This script first lists Tmux sessions in FZF, then projects from a file (Default: $HOME/.tmux-sessionizer.list). You can add or edit entries with tmux-sessionizer add or tmux-sessionizer edit.

Some other similar alternatives.

Commands

  • tmux-sessionizer switch: Fuzzy search through Tmux sessions and projects and switch/create a session for the selected entry.
  • tmux-sessionizer add [path] [name]: Add a new entry to the list file with the specified path and session name. If no path is provided, it defaults to pwd. If no name is provided, it defaults to basename of path.
  • tmux-sessionizer edit: Opens the sessionizer list file in editor. Refers $EDITOR, if not provided defaults to vim.
  • tmux-sessionizer sanitize: Remove duplicate and non-reachable entries from the list file.

Installation

  1. Clone the repository:

    git clone https://github.com/mnjm/tmux-sessionizer.git
  2. Add the script directory to your $PATH environment variable. For example, if you cloned the repository to ~/tmux-sessionizer, add the following line to your shell profile (e.g., .bashrc, .zshrc):

    export PATH="~/tmux-sessionizer:$PATH"

    (or) Copy / link tmux-sessionizer script in one of the entries directory in your $PATH For ex. ~/.local/bin

    cd ./tmux-sessionizer
    cp ./tmux-sessionizer ~/.local/bin
    (or)
    ln -s $(realpath tmux-sessionizer) ~/.local/bin/
  3. (Optional) you can add it as an alias in your shell config (.bashrc or .zshrc):

    alias tmuxs='tmux-sessionizer switch'
    alias tmuxs-add='tmux-sessionizer add'
    alias tmuxs-edit='tmux-sessionizer edit'
  4. (Optional) you can add it as a binding in your tmux config (.tmux.conf):

    bind s display-popup 'tmux-sessionizer switch'

Configuration

Environment variables

  • TMUX_SEZ_LIST_FILE: Path to the list file. Default: $HOME/.tmux-sessionizer.list
  • TMUX_SEZ_FZF_COMMAND: Custom fzf command. Default: fzf --height 100% --reverse

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request

License

This project is licensed under the MIT License.

About

Tmux Sessionizer: Bash script for creating/switching between tmux sessions using fzf

Topics

Resources

License

Stars

Watchers

Forks

Languages