Skip to content

Add dot alias to resolve current worktree#16

Merged
bkildow merged 1 commit intomainfrom
feature/dot-alias
Mar 25, 2026
Merged

Add dot alias to resolve current worktree#16
bkildow merged 1 commit intomainfrom
feature/dot-alias

Conversation

@bkildow
Copy link
Copy Markdown
Owner

@bkildow bkildow commented Mar 25, 2026

Summary

  • Adds . as a special argument to wt remove, wt open, wt cd, and wt apply to target the worktree the user is currently inside (works from subdirectories too)
  • For wt remove ., the process chdir's to the project root before git removes the directory, then the shell wrapper auto-cd's the user to the project root seamlessly
  • Adds remove to the shell wrapper's intercepted commands (bash, zsh, fish) so the auto-cd works
  • Extracts selectWorktree and findWorktreeByBranch helpers to DRY up duplicated worktree resolution logic across all four commands
  • Adds . to tab completion for discoverability

Test plan

  • make dev passes (fmt, lint, tests, build)
  • cd worktrees/<branch> && wt open . opens current worktree in editor
  • cd worktrees/<branch> && wt cd . prints current worktree path
  • cd worktrees/<branch> && wt apply . applies shared files to current worktree
  • cd worktrees/<branch> && wt remove . removes worktree and shell lands at project root (with wrapper)
  • cd worktrees/<branch>/some/subdir && wt open . resolves correctly from subdirectory
  • From project root: wt remove . returns "not inside a managed worktree" error
  • wt remove <branch> while inside that worktree also works seamlessly (chdir protection fires for any targeting, not just .)
  • Tab completion shows . in the list
  • Re-source shell wrapper: eval "$(wt shell-init zsh)" picks up the new remove interception

Support "." as a special argument in wt remove, open, cd, and apply to
target the worktree the user is currently inside. This parallels the
existing "wt cd .." shorthand for the project root.

For wt remove, when the user is inside the target worktree, the process
chdir's to the project root before invoking git worktree remove, and
prints the project root to stdout so the shell wrapper auto-cd's the
user there seamlessly.

Also extracts selectWorktree/findWorktreeByBranch helpers to DRY up the
duplicated worktree resolution logic across all four commands.
@bkildow bkildow merged commit 8b62a1f into main Mar 25, 2026
@bkildow bkildow deleted the feature/dot-alias branch March 25, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant