Skip to content
Open
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
3 changes: 3 additions & 0 deletions lua/sidekick/cli/session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function B:attach() end
--- Detach from an existing session
function B:detach() end

--- Focus an external session (tmux/zellij pane)
function B:focus() end

--- Start a new session
--- If the backend returns a Cmd, a new terminal session will be spawned
---@return sidekick.cli.terminal.Cmd?
Expand Down
10 changes: 10 additions & 0 deletions lua/sidekick/cli/session/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,14 @@ function M:dump()
return ret
end

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

return M
10 changes: 8 additions & 2 deletions lua/sidekick/cli/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,14 @@ function M.attach(state, opts)
terminal:focus()
end
end
elseif attached then
Util.info("Attached to `" .. state.tool.name .. "`")
else
-- External session (tmux/zellij pane)
if opts.focus and state.external and session.focus then
session:focus()
end
if attached then
Util.info("Attached to `" .. state.tool.name .. "`")
end
end
return state, attached
end
Expand Down