Skip to content

v0.5.0

Latest

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