Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/sidekick/cli/session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function B.sessions()
error("Backend:sessions() not implemented")
end

function B.focus() end

---@param state sidekick.cli.session.Opts
function M.new(state)
local tool = state.tool
Expand Down
11 changes: 11 additions & 0 deletions lua/sidekick/cli/session/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function M:start()
elseif Config.cli.mux.create == "split" then
local cmd = { "tmux", "split-window", "-dP", "-c", self.cwd, "-F", PANE_FORMAT }
cmd[#cmd + 1] = Config.cli.mux.split.vertical and "-h" or "-v"
if Config.cli.win.layout == "left" or Config.cli.win.layout == "top" then
cmd[#cmd + 1] = "-b"
end
local size = Config.cli.mux.split.size
vim.list_extend(cmd, { "-l", tostring(size <= 1 and ((size * 100) .. "%") or size) })
self:add_cmd(cmd)
Expand Down Expand Up @@ -196,4 +199,12 @@ function M:dump()
return ret
end

---Focus the tmux pane (select it as the active pane)
function M:focus()
local pane_id = self:pane_id()
if pane_id then
Util.exec({ "tmux", "select-pane", "-t", pane_id })
end
end

return M
1 change: 1 addition & 0 deletions lua/sidekick/cli/session/zellij.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function M.sessions()
return ret
end

function M.focus() end
-- function M:dump()
-- do
-- -- sigh, another broken zellij feature
Expand Down
2 changes: 2 additions & 0 deletions lua/sidekick/cli/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ function M.attach(state, opts)
terminal:focus()
end
end
elseif session.focus and opts.focus ~= false then
session:focus()
elseif attached then
Util.info("Attached to `" .. state.tool.name .. "`")
end
Expand Down
Loading