How can I have multiple sidekick cli sessions attached to a single directory #208
Unanswered
Raaghav-Arya
asked this question in
Q&A
Replies: 1 comment
-
|
This work-around works for me: -- HACK: multiple claude/opencode sessions per cwd, add claude_glm tool
{
"folke/sidekick.nvim",
optional = true,
keys = function(_, keys)
local mappings = {}
local tools = {
["<leader>ac"] = "claude",
["<leader>ao"] = "opencode",
["<leader>ag"] = "claude_glm",
}
for key, tool in pairs(tools) do
local desc = tool:gsub("_", " "):gsub("^%l", string.upper)
-- stylua: ignore
vim.list_extend(mappings, {
{ key, function() require("sidekick.cli").show(tool .. (vim.v.count == 0 and "" or vim.v.count)) end, desc = desc },
{ key, function() require("sidekick.cli").send(tool .. (vim.v.count == 0 and "" or vim.v.count), { msg = "{this}" }) end, mode = "x", desc = desc },
})
end
return vim.list_extend(keys, mappings)
end,
---@param opts sidekick.Config
config = function(_, opts)
local Config = require("sidekick.config")
opts.cli = opts.cli or {}
opts.cli.tools = opts.cli.tools or {}
---@param _opts { name: string, base_tool?: string, tool_opts?: sidekick.cli.Config|{}, count?: number }
local function numbered_tools(_opts)
---@param name string
---@return sidekick.cli.Config|{}, string|nil
local function get_tool(name)
local tool = vim.tbl_deep_extend("force", Config.get_tool(name).config or {}, opts.cli.tools[name] or {})
tool = vim.deepcopy(tool)
return tool, tool.cmd and tool.cmd[1]
end
local name, base_name = _opts.name, _opts.base_tool or _opts.name
local base, base_exe = get_tool(base_name)
local base_exepath = base_exe and vim.fn.exepath(base_exe) or ""
if base_exepath == "" then
return
end
local function register(tool)
local dest = vim.fs.joinpath(vim.fn.expand("~/.local/bin"), tool)
if not vim.uv.fs_stat(dest) then
vim.uv.fs_symlink(base_exepath, dest) -- use symlink to make `is_proc` behave
end
opts.cli.tools[tool] = vim.tbl_deep_extend("force", vim.deepcopy(base), _opts.tool_opts or {})
opts.cli.tools[tool].cmd[1], opts.cli.tools[tool].is_proc = tool, "\\<" .. tool .. "\\>"
end
if name ~= base_name and not get_tool(name).cmd then
register(name) -- for `claude_glm` (without number suffix)
end
for i = 1, _opts.count or 5 do
register(name .. i)
end
end
numbered_tools({ name = "claude" })
numbered_tools({ name = "opencode" })
numbered_tools({
name = "claude_glm",
base_tool = "claude",
tool_opts = { env = U.ai.claude.provider.plan.glm },
})
require("sidekick").setup(opts)
end,
}, |
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.
-
Hi,
I want to have multiple claude code instances for the same directory.
I use tmux as my mux.
When I run the command:
It shown an option to open a new cli session only if a session attached to any previous directory is not there.
Otherwise it only shows a list of existing cli sessions.
Beta Was this translation helpful? Give feedback.
All reactions