Replies: 6 comments 5 replies
-
|
i'm working on plugin apis, which would enable sharable plugins like this, but its nowhere near to finalize yet. however your case should still be possible even today, i think. herdr cli has workspace creation, pane creation, and custom commands. so you can bind custom commands to keybinds, which could call herdr cli to create workspace with mise commands for instance. |
Beta Was this translation helpful? Give feedback.
-
|
Came here to suggest the same. Automatic setup and teardown scripts for worktrees would be great. |
Beta Was this translation helpful? Give feedback.
-
|
for anyone who would like to have this, you can do this today with a custom command + script. later i might add more apis for automatic runnable scripts but my idea for now instead of adding more native support, bringing api based plugin system so people can share their plugins, scripts and reusable flows. for now, it would not be automatic for every worktree creation, but if you create worktrees through this command it can run your setup steps right after creating the checkout. when you press the keybind, the script prompts for the branch name. that value is used both as the git branch and as the herdr workspace label. example config: [[keys.command]]
key = "prefix+alt+w"
type = "pane"
command = "$HOME/.local/bin/herdr-new-worktree"
description = "new worktree with setup"example script: #!/usr/bin/env bash
set -euo pipefail
herdr_bin="${HERDR_BIN_PATH:-herdr}"
source_cwd="${HERDR_ACTIVE_PANE_CWD:-$PWD}"
source_root="$(git -C "$source_cwd" rev-parse --show-toplevel)"
read -rp "branch name: " branch
[ -n "$branch" ]
response="$("$herdr_bin" worktree create \
--cwd "$source_root" \
--branch "$branch" \
--label "$branch" \
--no-focus \
--json)"
workspace_id="$(jq -r '.result.workspace.workspace_id' <<<"$response")"
pane_id="$(jq -r '.result.root_pane.pane_id' <<<"$response")"
checkout="$(jq -r '.result.worktree.path' <<<"$response")"
[ -f "$source_root/.env" ] && cp "$source_root/.env" "$checkout/.env"
cd "$checkout"
command -v mise >/dev/null 2>&1 && mise trust || true
command -v direnv >/dev/null 2>&1 && direnv allow || true
"$herdr_bin" pane run "$pane_id" "git status --short"
"$herdr_bin" workspace focus "$workspace_id"then: chmod +x ~/.local/bin/herdr-new-worktree
herdr server reload-configimportant detail: use |
Beta Was this translation helpful? Give feedback.
-
|
closing since manual scripts like above supports this for now, after the plugin release these scripts should be shareable via plugin ecosystem easiy. |
Beta Was this translation helpful? Give feedback.
-
|
hey, 0.7.0 is out and it brings the new plugin system: https://herdr.dev/docs/plugins/ this looks like a good candidate for a plugin instead of a built-in herdr feature, so i'm going to close this discussion for now. if you build or find a plugin for this workflow, please share it here so others can use it too. |
Beta Was this translation helpful? Give feedback.
-
|
Built this as a plugin, as suggested: tdi/herdr-worktree-setup On Install: Tagged |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
idea / problem
When creating a worktree there are some files or commands that make the worktree directory - "usable" e.g. mise trust, direnv allow or copy *.env from main
requested change
Add setup script per space configurable by user - similar to what conuctor does.
why you want this
Makes life easier nad streamlines the development
Beta Was this translation helpful? Give feedback.
All reactions