Multi-session AI CLI integration for Neovim using sidekick.nvim + tmux #268
Raaghav-Arya
started this conversation in
Show and tell
Replies: 1 comment
-
|
Hi. I had raised a Q&A for this earlier. That discussion can be found here: #208 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Multi-session AI CLI integration for Neovim using sidekick.nvim + tmux
I've been building out a multi-session AI CLI setup on top of sidekick.nvim and wanted to share it. The core idea: run any number of named AI CLI sessions (e.g.
claude_1,claude_2, …) in tmux, each independently togglable from Neovim, with exclusive visibility and automatic restore when reopening a project.Features
Multiple named sessions — sessions are unlimited;
<leader>analways opens a new one in the next free slot.<leader>a1–<leader>a5are dedicated shortcuts for the first five. Opening any session auto-hides all others so you never have overlapping terminals cluttering your layout.Session picker —
<leader>aaopens a fuzzy picker listing every session with its status ([visible],[attached], or registered-but-not-open). Pressdin the picker to sendexitto a session without leaving the picker.Session restore — on
SessionLoadPost, tmux sessions with a matching cwd are silently re-registered. No windows open automatically; just pick the one you want from the picker.Send helpers — route code to whichever session is currently active:
<leader>a1–<leader>a5<leader>anfor more<leader>as<leader>an<leader>aadto delete)<leader>ak<leader>ax<leader>ad<leader>at<leader>av<leader>af<leader>ap<leader>ay<Tab>Portable — change
local CLI_TOOL = "claude"at the top of the file to any tool sidekick supports ("gemini","copilot", etc.). All session names, patterns, commands, and notifications derive from that one variable.Implementation notes
A few non-obvious things I ran into:
No
is_procon named tools — only the bareclaudetool hasis_proc, so sidekick's tmux process-discovery doesn't conflict across multiple sessions. Named tools (claude_1etc.) are registered dynamically inrequire("sidekick.config").cli.toolsat runtime, not in the staticopts.Session restore without opening windows — after a Neovim restart, sidekick re-discovers tmux sessions but assigns them all to the bare
claudetool. The original name (claude_N) is preserved in the tmux session name (mux_session), formatted as"<tool_name> <sha256_prefix>". TheSessionLoadPostautocmd parses that field to recover the name and re-registers the tool config — noSession.attach()ortoggle()is called, so no windows open.Kill coverage —
<leader>akhandles three session states: attached with amux_sessionfield, attached without one, and registered-only (never opened since restore). The last case usesSession.sid()to compute the tmux session name.Full config
lua/plugins/sidekick.luaBeta Was this translation helpful? Give feedback.
All reactions