From 39030e3486bd38107240c7d7204b9d6fda368fab Mon Sep 17 00:00:00 2001 From: Andrew Stilliard Date: Mon, 24 Aug 2026 15:58:09 +0100 Subject: [PATCH] feat(alias): `create` for mk, `del` for rm Adds two more command aliases alongside the existing add/remove/list, wired into the dispatcher, the zsh/bash completions and the help text. Co-Authored-By: Claude Opus 5 (1M context) --- README.md | 2 +- test/mk.bats | 8 ++++++++ test/rm.bats | 7 +++++++ wt.sh | 10 +++++----- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 629626a..6c4979f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ wt cd # explicit cd (same as wt ) 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/` 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. diff --git a/test/mk.bats b/test/mk.bats index 902d939..2fb0173 100644 --- a/test/mk.bats +++ b/test/mk.bats @@ -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")" diff --git a/test/rm.bats b/test/rm.bats index 456a614..f86cb72 100644 --- a/test/rm.bats +++ b/test/rm.bats @@ -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" diff --git a/wt.sh b/wt.sh index b0a8134..c541a6e 100644 --- a/wt.sh +++ b/wt.sh @@ -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 @@ -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 }" ;; @@ -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) matches=($(_wt_branches)) compadd -M 'l:|=*' -a matches ;; @@ -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