Skip to content

Commit edb707f

Browse files
committed
docs: re-record GIFs with vhs, add shell integration to demo
- Switch from shellwright to vhs for GIF recording (proper timing) - Add vhs tape files for all 5 demos (quickstart, create, hooks, multi-repo, info) - Enable shell integration in Docker image so prompt updates after wt co - Clean up README: remove duplications, better structure
1 parent 836d7e2 commit edb707f

13 files changed

Lines changed: 236 additions & 178 deletions

README.md

Lines changed: 15 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ eval "$(wt shellenv)"
123123

124124
**Note for zsh users:** Place this after `compinit` in your config file.
125125

126-
127126
## Usage
128127

129128
### Checkout & Create
@@ -164,12 +163,15 @@ wt rm old-branch # remove a worktree
164163
wt rm # interactive: select worktree to remove
165164
```
166165

167-
### Maintenance
166+
### Maintenance & Misc
168167

169168
```bash
170169
wt migrate # migrate worktrees to configured paths
171170
wt migrate --force # force when target path exists
172171
wt prune # clean up stale worktree admin files
172+
wt version # show version
173+
wt examples # show practical examples
174+
wt --help # show help
173175
```
174176

175177
### Info & Config
@@ -183,110 +185,34 @@ wt config init # create a default config file
183185
wt config path # print the config file path
184186
```
185187

186-
### Shell Integration & Misc
187-
188-
```bash
189-
wt init # auto-detect shell and configure
190-
wt init --uninstall # remove shell integration
191-
wt shellenv # print shell integration code
192-
wt version # show version
193-
wt examples # show practical examples
194-
wt --help # show help
195-
```
196-
197-
### JSON Output (`--format json`)
198-
199-
Most commands support machine-readable JSON output:
200-
201-
```bash
202-
wt --format json version
203-
wt --format json info
204-
wt --format json config show
205-
wt --format json list
206-
wt --format json examples
207-
wt --format json # root help in JSON envelope
208-
```
209-
210-
Important behavior for shell integration:
211-
212-
- In `text` mode (default), shell integration may auto-navigate to the target worktree.
213-
- In `json` mode, output is kept machine-readable and shell integration does **not** auto-navigate.
214-
215-
For commands that normally prompt interactively (`wt co`, `wt rm`, `wt pr`, `wt mr`), pass explicit arguments when using `--format json`.
216-
217188
### Interactive Selection
218189

219190
When you run `wt co`, `wt rm`, `wt pr`, or `wt mr` without arguments, you'll get an interactive selection menu:
220191

221192
```bash
222-
# Interactive branch checkout
223193
$ wt co
224194
Use the arrow keys to navigate: ↓ ↑ → ←
225195
? Select branch to checkout:
226196
▸ feature/add-auth
227197
feature/update-docs
228198
bugfix/login-issue
229199
main
230-
231-
# Interactive worktree removal
232-
$ wt rm
233-
Use the arrow keys to navigate: ↓ ↑ → ←
234-
? Select worktree to remove:
235-
▸ feature/add-auth
236-
feature/update-docs
237-
bugfix/login-issue
238-
239-
# Interactive PR checkout — resolves to the PR's branch name (requires gh CLI)
240-
$ wt pr
241-
Use the arrow keys to navigate: ↓ ↑ → ←
242-
? Select Pull Request:
243-
#123: Add authentication feature
244-
#124: Update documentation
245-
#125: Fix login bug
246-
# e.g. selecting #123 creates worktree at ~/dev/worktrees/<repo>/feat/add-auth
247-
248-
# Interactive MR checkout — resolves to the MR's branch name (requires glab CLI)
249-
$ wt mr
250-
Use the arrow keys to navigate: ↓ ↑ → ←
251-
? Select Merge Request:
252-
!456: Add authentication feature
253-
!457: Update documentation
254-
!458: Fix login bug
255-
# e.g. selecting !456 creates worktree at ~/dev/worktrees/<repo>/feat/add-auth
256200
```
257201

258-
### Examples
259-
260-
```bash
261-
# Create a new feature branch from main
262-
wt create add-auth-feature
263-
264-
# Checkout an existing branch
265-
wt checkout bugfix-login
266-
267-
# Work on a GitHub PR (checks out the PR's branch, e.g. feat/add-auth)
268-
wt pr 456
269-
270-
# Work on a GitLab MR (checks out the MR's branch, e.g. fix/api-cleanup)
271-
wt mr 789
272-
273-
# List all your worktrees
274-
wt list
275-
276-
# Remove a worktree when done
277-
wt rm add-auth-feature
278-
279-
# Show full examples catalog (filter with rg/grep if needed)
280-
wt examples
202+
### JSON Output (`--format json`)
281203

282-
# Each example includes outcome + path illustration based on config pattern
283-
# e.g. path example: $WORKTREE_ROOT/<repo>/<branch> -> (removed)
284-
# and concrete text/json output samples where relevant
204+
Most commands support machine-readable JSON output:
285205

286-
# JSON mode does not auto-navigate; use returned navigate_to
287-
wt --format json create add-auth-feature
206+
```bash
207+
wt --format json version
208+
wt --format json info
209+
wt --format json config show
210+
wt --format json list
211+
wt --format json examples
288212
```
289213

214+
In `json` mode, shell integration does **not** auto-navigate. For commands that normally prompt interactively, pass explicit arguments when using `--format json`.
215+
290216
## Configuration
291217

292218
### Configuration File
@@ -334,17 +260,10 @@ Configuration values are resolved in this order (highest priority first):
334260

335261
Run `wt config show` to see the effective value and source of each setting.
336262

337-
### Worktree Location
263+
### Strategies & Patterns
338264

339265
By default, worktrees are created at `~/dev/worktrees/<repo>/{.branch}` using the `global` strategy.
340266

341-
Configure the location with environment variables or the config file:
342-
343-
- `WORKTREE_ROOT` / `root` (default: `~/dev/worktrees`)
344-
- `WORKTREE_STRATEGY` / `strategy` (`global`, `sibling-repo`, `parent-branches`, `parent-worktrees`, `parent-dotdir`, `inside-dotdir`, `custom`)
345-
- `WORKTREE_PATTERN` / `pattern` (optional; overrides the default structure within the chosen strategy)
346-
- `WORKTREE_SEPARATOR` / `separator` (default: `/`; controls how `/` and `\` in value variables are replaced)
347-
348267
Available pattern variables:
349268

350269
- `{.repo.Name}` repo name
@@ -378,49 +297,12 @@ The `separator` setting controls how `/` and `\` characters in **value variables
378297
| `_` | `feat_foo` (flat) | Alternative flat layout |
379298
| `""` | `featfoo` | Compact (rarely used) |
380299

381-
```toml
382-
# ~/.config/wt/config.toml
383-
separator = "-" # feat/foo -> feat-foo
384-
```
385-
386-
```bash
387-
export WORKTREE_SEPARATOR="-"
388-
```
389-
390-
Customize the location via environment variables:
391-
392-
```bash
393-
export WORKTREE_ROOT="$HOME/projects/worktrees"
394-
export WORKTREE_STRATEGY="sibling-repo"
395-
export WORKTREE_SEPARATOR="-"
396-
export WORKTREE_PATTERN="{.repo.Main}/../{.repo.Name}/{.branch}"
397-
```
398-
399-
Or via config file:
400-
401-
```toml
402-
root = "~/projects/worktrees"
403-
strategy = "sibling-repo"
404-
separator = "-"
405-
pattern = "{.repo.Main}/../{.repo.Name}/{.branch}"
406-
```
407-
408-
Run `wt info` to see the active strategy, pattern, and available variables.
409-
410300
### Hooks
411301

412302
Hooks let you run custom commands before or after `wt` operations. Define them in the `[hooks]` section of your config file:
413303

414304
![wt hooks](docs/wt-hooks.gif)
415305

416-
```toml
417-
# ~/.config/wt/config.toml
418-
[hooks]
419-
post_create = ["test -f $WT_MAIN/.env && cp $WT_MAIN/.env $WT_PATH/.env || true"]
420-
post_checkout = ["cd $WT_PATH && npm install"]
421-
pre_remove = ["echo Removing worktree at $WT_PATH"]
422-
```
423-
424306
**Available hooks:**
425307

426308
| Hook | When it runs |
@@ -506,32 +388,9 @@ strategy = "custom"
506388
pattern = "{.worktreeRoot}/{.env.FEATURE}/{.repo.Name}"
507389
```
508390

509-
Set the `FEATURE` environment variable and create worktrees across repos:
510-
511391
```bash
512392
export FEATURE=PROJ-42-new-checkout
513393

514-
cd ~/src/frontend
515-
wt create main # any branch name works; layout is driven by FEATURE
516-
517-
cd ~/src/backend
518-
wt create main
519-
```
520-
521-
This groups all repositories for a feature together:
522-
523-
```
524-
~/dev/worktrees/
525-
PROJ-42-new-checkout/
526-
frontend/
527-
backend/
528-
```
529-
530-
Switch to a different feature by changing the variable:
531-
532-
```bash
533-
export FEATURE=PROJ-99-hotfix
534-
535394
cd ~/src/frontend
536395
wt create main
537396

@@ -544,9 +403,6 @@ wt create main
544403
PROJ-42-new-checkout/
545404
frontend/
546405
backend/
547-
PROJ-99-hotfix/
548-
frontend/
549-
backend/
550406
```
551407

552408
If the referenced environment variable is not set, `wt` will return an error.
@@ -604,16 +460,6 @@ The tool wraps Git's native worktree commands with a convenient interface and or
604460
4. **Auto-CD**: With shell integration, automatically changes to the worktree directory
605461
5. **Tab Completion**: Makes it easy to work with existing branches
606462

607-
## Comparison with Original
608-
609-
This Go port maintains feature parity with the original bash script while offering:
610-
611-
- Faster execution (compiled binary)
612-
- No bash dependency
613-
- Easier to distribute (single binary)
614-
- Cross-platform support (builds on Windows, macOS, Linux)
615-
- Built-in completion support via cobra
616-
617463
## License
618464

619465
MIT

docs/demo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ error_symbol = "[❯](bold red)"\n\
4444
' > .config/starship.toml
4545

4646
# Bake starship init into .bashrc so it activates even with bare bash
47-
RUN printf 'eval "$(starship init bash)"\n' > .bashrc
47+
RUN printf 'eval "$(starship init bash)"\neval "$(wt shellenv)"\n' > .bashrc
4848

4949
# Create main-app repo with branches and .env
5050
RUN mkdir -p src/main-app && cd src/main-app && git init && \

docs/demo/create.tape

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Output "../wt-create.gif"
2+
3+
Set Theme "Dracula"
4+
Set FontSize 16
5+
Set Width 1200
6+
Set Height 600
7+
Set TypingSpeed 30ms
8+
Set Padding 20
9+
10+
Hide
11+
Type "docker run --rm -it -e WORKTREE_ROOT=/home/demo/worktrees wt-demo bash --rcfile /home/demo/.bashrc"
12+
Enter
13+
Sleep 3s
14+
Type "cd src/main-app"
15+
Enter
16+
Sleep 1s
17+
Type "clear"
18+
Enter
19+
Sleep 1s
20+
Show
21+
22+
Type "wt create feat/new-feature"
23+
Enter
24+
Sleep 4s
25+
26+
Type "wt ls"
27+
Enter
28+
Sleep 6s
29+
30+
Type "wt rm feat/new-feature"
31+
Enter
32+
Sleep 4s
33+
34+
Type "wt ls"
35+
Enter
36+
Sleep 6s
37+
38+
Sleep 5s

docs/demo/hooks.tape

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Output "../wt-hooks.gif"
2+
3+
Set Theme "Dracula"
4+
Set FontSize 16
5+
Set Width 1200
6+
Set Height 600
7+
Set TypingSpeed 30ms
8+
Set Padding 20
9+
10+
Hide
11+
Type "docker run --rm -it -e WORKTREE_ROOT=/home/demo/worktrees -e WT_CONFIG=/home/demo/.config/wt/variants/hooks.toml wt-demo bash --rcfile /home/demo/.bashrc"
12+
Enter
13+
Sleep 3s
14+
Type "cd src/main-app"
15+
Enter
16+
Sleep 1s
17+
Type "clear"
18+
Enter
19+
Sleep 1s
20+
Show
21+
22+
Type "cat .env"
23+
Enter
24+
Sleep 4s
25+
26+
Type "wt co fix/login-bug"
27+
Enter
28+
Sleep 4s
29+
30+
Type "cat ~/worktrees/main-app/fix/login-bug/.env"
31+
Enter
32+
Sleep 6s
33+
34+
Sleep 5s

docs/demo/info.tape

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Output "../wt-info.gif"
2+
3+
Set Theme "Dracula"
4+
Set FontSize 16
5+
Set Width 1200
6+
Set Height 600
7+
Set TypingSpeed 30ms
8+
Set Padding 20
9+
10+
Hide
11+
Type "docker run --rm -it -e WORKTREE_ROOT=/home/demo/worktrees wt-demo bash --rcfile /home/demo/.bashrc"
12+
Enter
13+
Sleep 3s
14+
Type "cd src/main-app"
15+
Enter
16+
Sleep 1s
17+
Type "clear"
18+
Enter
19+
Sleep 1s
20+
Show
21+
22+
Type "wt info"
23+
Enter
24+
Sleep 5s
25+
26+
Type "wt config show"
27+
Enter
28+
Sleep 6s
29+
30+
Sleep 5s

0 commit comments

Comments
 (0)