Repository navigation
Releases
Releases · haxybaxy/rex-worktrunk
v0.5.0
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-worktrunkv0.4.0
Worktrees can now open as tabs in one session per repository, in place of a session per worktree (#7, #8).
Added
- With
group = "tab", each repository has one session, and each of its worktrees is a tab in it.group = "session"stays the default.- Tabs open in the session your main checkout is in, if you have picked from it there. Otherwise the plugin creates a session named after the main checkout's directory.
- A tab is labelled with its branch. The
labelandlayoutoptions apply to the tab. - Removing a worktree closes its tab and returns you to the tab you came from, or else the main checkout's tab. The session stays open. A session the plugin created is closed with its last tab.
- Changing
grouponly affects worktrees opened afterwards. A worktree that already has a session or tab keeps it until it is removed.
worktree_goandworktree_closealso returnwindow_id, andworktree_closereturnsmoved_to_window.
Changed
- Two messages of
worktrunk.shnow say "session or tab". - With the default
group = "session", the plugin makes the same calls to Rex as 0.3.0.
Upgrade notes
- The registry file (
~/.local/state/rex-worktrunk/sessions) keeps its format for worktrees that have a session of their own, and gains fields for tabs. 0.3.0 and earlier don't know those fields and would treat a worktree's tab as a whole session. Before going back to an older version, remove the worktrees you opened as tabs, or delete the file.
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).
group = "tab"was tested with Rex server API revision 19.
Install
git clone --branch v0.4.0 https://github.com/haxybaxy/rex-worktrunk ~/.config/rex/rex-worktrunkv0.3.0
The pickers can now list in Rex's command palette, in place of fzf in a floating terminal (#5).
Added
- With
picker = "native", the pickers list worktrees and branches in Rex's command palette.picker = "float"stays the default.- Picking an existing worktree switches straight to its session, with no float. This needs no Remote Control.
- Creating a worktree (a new name, a branch without one,
pr:N) and removing one still run in the float, without fzf. That keeps worktrunk's hooks, approval prompts and errors visible. - The fzf float is used when Rex can't show a prompt in the palette, and in sessions on remote hosts.
gitandwtrun through your login shell, so they're found on the samePATHas in your terminals.
worktrunk.sh switch NAME [--base BRANCH] [--slugify]andworktrunk.sh remove NAMEact on a name chosen elsewhere, without fzf.
Changed
- A new demo video in the README.
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). With it, fzf is used only when the picker falls back to the float.
Install
git clone --branch v0.3.0 https://github.com/haxybaxy/rex-worktrunk ~/.config/rex/rex-worktrunkv0.2.0
The first tagged release of rex-worktrunk. It covers everything since the initial 0.1.0 commit.
Added
- A
labeloption chooses the label of a new session (#2). labelandlayoutreceive a worktree table withpath,branchandmain.- Closing a worktree's session returns you to the session the worktree was opened from. If that session is gone, you go to the main checkout's session. A session is never created only to leave one.
- The session a pick was made from is adopted for the worktree it is in. It is reused on later picks and never closed, so picking the main checkout's branch no longer opens a second session.
- Closing is idempotent, so a worktrunk
post-removehook and the picker can both close the same worktree. - A test suite (
bash test/run.sh) that runs in GitHub Actions on each push tomainand each pull request.
Fixed
- The picker works in a session on a remote Rex server: a script under your home directory is started as
$HOME/<the rest of its path>on the host the float runs on (#1). - Sessions are found by worktree path, never by label, so a session is only reused or closed for the worktree it was opened for (#2).
- A failed close keeps the session on record, so you can try again.
- A label that Rex refuses falls back to the directory name. Options of the wrong type are ignored with a warning.
worktrunk.shworks from a bare repository's root and doesn't wait for a key without a terminal.
Requirements
worktrunk (wt ≥ 0.60), fzf and jq. Tested with worktrunk 0.63 and 0.81.
Install
git clone --branch v0.2.0 https://github.com/haxybaxy/rex-worktrunk ~/.config/rex/rex-worktrunkThanks to sf-jin-ku and disrupted for their contributions.