Skip to content
Discussion options

You must be logged in to vote

I created a zsh wrapper function around claude --worktree, seems to mostly do the trick for me:

cw() {
  local name="$1"
  [[ -z "$name" ]] && { print -u2 "usage: cw <worktree-name> [claude args...]"; return 1; }
  [[ "$name" == -* ]] && { print -u2 "cw: first argument must be a worktree name, not an option: $name"; return 1; }
  shift

  local old_pwd="$PWD"
  local wt_dir="$PWD/.claude/worktrees/$name"

  mkdir -p "$wt_dir" || return 1
  builtin cd "$wt_dir" || return 1

  claude --worktree "$name" "$@"
  local rc=$?

  builtin cd "$old_pwd"
  return $rc
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by manfredlift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant