Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ wt cd <name> # explicit cd (same as wt <name>)
wt help # show usage
```

Aliases: `add` → `mk`, `remove` → `rm`, `list` → `ls`
Aliases: `add`/`create` → `mk`, `remove`/`del` → `rm`, `list` → `ls`

Worktrees are created in `.claude/worktrees/<branch>` inside the repo, the same place Claude Code puts them, so both tools see the same set. Add `.claude/worktrees/` to your `.gitignore` if it isn't already. Slashes in a branch name become dashes in the folder.

Expand Down
8 changes: 8 additions & 0 deletions test/mk.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ teardown() { wt_common_teardown; }
git worktree remove "$expected"
}

@test "wt create alias creates worktree" {
local branch="via-create"
local expected="$(wt_dest "$branch")"
wt create "$branch"
[ -d "$expected" ]
git worktree remove "$expected"
}

@test "wt mk replaces slashes in branch name with dashes" {
local branch="type/my-thing"
local expected="$(wt_dest "$branch")"
Expand Down
7 changes: 7 additions & 0 deletions test/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ teardown() { wt_common_teardown; }
[ ! -d "$TEST_REPO-other" ]
}

@test "wt del alias removes a worktree" {
git -C "$TEST_REPO" worktree add -q "$TEST_REPO-viadel" -b via-del
run wt del via-del
[ "$status" -eq 0 ]
[ ! -d "$TEST_REPO-viadel" ]
}

@test "wt rm refuses to remove the main worktree by branch name" {
local branch; branch=$(git -C "$TEST_REPO" rev-parse --abbrev-ref HEAD)
run wt rm "$branch"
Expand Down
10 changes: 5 additions & 5 deletions wt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Commands:
wt merged [base] [opts] list worktrees merged into base (default: main/master)
wt help show this help

Aliases: add=mk, remove=rm, list=ls
Aliases: add/create=mk, remove/del=rm, list=ls

Options (ls|merged):
--claude show a table of Claude Code agent sessions per worktree
Expand Down Expand Up @@ -481,8 +481,8 @@ EOF
wt() {
case "${1-}" in
''|ls|list) _wt_ls "${@:2}" ;;
mk|add) _wt_mk "${@:2}" ;;
rm|remove) _wt_rm "${@:2}" ;;
mk|add|create) _wt_mk "${@:2}" ;;
rm|remove|del) _wt_rm "${@:2}" ;;
prune) _wt_prune ;;
merged) _wt_merged "${@:2}" ;;
cd) _wt_cd "${2?usage: wt cd <name>}" ;;
Expand Down Expand Up @@ -522,7 +522,7 @@ if [ -n "$ZSH_VERSION" ]; then
matches=(root $(_wt_branches))
compadd -M 'l:|=*' -a matches
;;
rm|remove|merged)
rm|remove|del|merged)
Comment thread
stilliard marked this conversation as resolved.
matches=($(_wt_branches))
compadd -M 'l:|=*' -a matches
;;
Expand Down Expand Up @@ -556,7 +556,7 @@ elif [ -n "$BASH_VERSION" ]; then
cd)
_wt_compreply "$cur" root $(_wt_branches)
;;
rm|remove|merged)
rm|remove|del|merged)
_wt_compreply "$cur" $(_wt_branches)
;;
esac
Expand Down