Repository navigation
A new on_created option runs a function of yours when a worktree's session or tab is created (#10). Thanks to @nianiam for the contribution.
Added
on_created = function(result, worktree)is called after a new session or tab is created.resultis whatworktree_goreturns:session_id,window_id,pathandcreated.worktreeis the same table thatlabelandlayoutget.- Call
rex.call("session.attach", { session_id = result.session_id })before acting on the session. - An error in the function is logged as a warning and doesn't fail the action.
- With
group = "tab", tabs the function opens aren't closed with the worktree.
require("rex-worktrunk").setup{
-- A second tab, "server", in each new worktree session
on_created = function(result, worktree)
rex.call("session.attach", { session_id = result.session_id })
rex.session.new_window{
session_id = result.session_id,
window_label = "server",
focus = false,
layout = rex.layout.block{ flavor = "com.superlogical.terminal.shell", options = { cwd = worktree.path } },
}
end,
}Changed
- Nothing changes when the option isn't set.
Requirements
- worktrunk (
wt≥ 0.60) and jq. - fzf, for the float picker.
- For the native picker: a Rex whose server and app can show palette prompts (server API revision 17 or later).
on_createdwas tested with Rex server API revision 19.
Install
git clone --branch v0.5.0 https://github.com/haxybaxy/rex-worktrunk ~/.config/rex/rex-worktrunk