Skip to content

Releases

v0.5.0

Choose a tag to compare

@haxybaxy haxybaxy released this 28 Nov 10:30
1ff9ba6

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.
    • result is what worktree_go returns: session_id, window_id, path and created. worktree is the same table that label and layout get.
    • 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_created was tested with Rex server API revision 19.

Install

git clone --branch v0.5.0 https://github.com/haxybaxy/rex-worktrunk ~/.config/rex/rex-worktrunk

v0.4.0

Choose a tag to compare

@haxybaxy haxybaxy released this 23 Nov 12:48
7465d64

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 label and layout options 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 group only affects worktrees opened afterwards. A worktree that already has a session or tab keeps it until it is removed.
  • worktree_go and worktree_close also return window_id, and worktree_close returns moved_to_window.

Changed

  • Two messages of worktrunk.sh now 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-worktrunk

v0.3.0

Choose a tag to compare

@haxybaxy haxybaxy released this 20 Nov 18:50
f6bf4ba

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.
    • git and wt run through your login shell, so they're found on the same PATH as in your terminals.
  • worktrunk.sh switch NAME [--base BRANCH] [--slugify] and worktrunk.sh remove NAME act 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-worktrunk

v0.2.0

Choose a tag to compare

@haxybaxy haxybaxy released this 11 Nov 17:44
332439b

The first tagged release of rex-worktrunk. It covers everything since the initial 0.1.0 commit.

Added

  • A label option chooses the label of a new session (#2).
  • label and layout receive a worktree table with path, branch and main.
  • 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-remove hook and the picker can both close the same worktree.
  • A test suite (bash test/run.sh) that runs in GitHub Actions on each push to main and 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.sh works 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-worktrunk

Thanks to sf-jin-ku and disrupted for their contributions.