Skip to content

Switching between multiple tmux sessions right from Neovim made easily

License

Notifications You must be signed in to change notification settings

jkeresman01/tmux-switch.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tmux-switch.nvim

Neovim plugin that allows you to switch between tmux sessions, right from Neovim, using fuzzy find functionality.

Lua Neovim 0.10 Work In Progress

Table of Contents

The problem ⚠️

When you are in Neovim, switching between multiple TMUX sessions can be cumbersome, requiring you to leave your editor and manually navigate the command line. This disrupts your workflow, especially when managing numerous sessions. The constant context-switching between the terminal and Neovim slows down productivity and can be frustrating for users who need a more seamless experience.


The solution πŸ†

TMUX Switch solves this problem by integrating fuzzy search within Neovim, allowing you to quickly switch between TMUX sessions without leaving your editor. By using this plugin, you can navigate and manage your TMUX sessions directly from Neovim which improves your overall productivity.

asciicast


Repository structure πŸ“‚

tmux-switch.nvim/
β”œβ”€β”€ LICENSE
β”œβ”€β”€ lua
β”‚   └── tmux-switch
β”‚       β”œβ”€β”€ commands.lua    # Commands exposed to Neovim
β”‚       β”œβ”€β”€ init.lua        # Plugin entry point
β”‚       β”œβ”€β”€ tmux.lua        # Tmux commands related logic
β”‚       β”œβ”€β”€ ui.lua          # UI logic (pickers and layout)
β”‚       └── util.lua        # Utility functions
└── README.md

Functionalities ⛏️

  • Fuzzy find trough all tmux session and navigate to selected one
  • Floating UI for creating new sessions
  • Floating UI for renaming current session
  • Quick switch between 2 most used sessions (works when the sort_by_recent_use option is set to true, then just enter the :TmuxSwitch command and select the first one)

Installation ⭐

  • Make sure you have Neovim v0.9.0 or greater. ❗
  • Dependecies: nui && telescope && plenary (telescope dep)
    • can be used without telescope, when the config option not_use_telescope is set to true. Then vim.ui.select is used.
  • Install using you plugin manager

Vim Plug

Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'MunifTanjim/nui.nvim'

Plug 'jkeresman01/tmux-switch.nvim'

Packer

use {
  'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or                            , branch = '0.1.x',
  requires = { {'nvim-lua/plenary.nvim'} }
}

use 'MunifTanjim/nui.nvim'

use 'jkeresman01/tmux-switch.nvim'

Commands πŸ”§

Following commands have been exposed to Neovim:

Commands

:TmuxSwitch             -- Lunch picker (select tmux session to switch to)
:TmuxCreateSession      -- Create new session and give it a name
:TmuxRenameSession      -- Rename current tmux session

Setup πŸ”§

Set the keybindings as you see fit, here is one example:

require('tmux-switch').setup({})

vim.keymap.set("n", "<C-f>", "<CMD>TmuxSwitch<CR>")
vim.keymap.set("n", "<leader>cs", "<CMD>TmuxCreateSession<CR>"
vim.keymap.set("n", "<leader>rs", "<CMD>TmuxRenameSession<CR>"

Keybindings Action
<C-f> Lunch TMUX switch UI (fuzzy search trough tmux sessions)
<leader>cs Lunch TMUX switch UI (create new TMUX session and name it)
<leader>rs Lunch TMUX switch UI (rename current TMUX session)