Skip to content

Commit 73858a7

Browse files
timvwclaude
andcommitted
docs: clarify shellenv should be added at end of config file
Revert the compdef check and instead document that users should add 'source <(wt shellenv)' at the END of their ~/.zshrc or ~/.bashrc, after compinit (for zsh users). This is simpler and follows the standard pattern used by other CLI tools. The compdef error will be avoided by proper placement in the config file. Changes: - Update shellenv help text to emphasize END of config file - Add note for zsh users to place after compinit - Update README with same instructions - Revert compdef existence check (no longer needed) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6dc990a commit 73858a7

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ sudo cp bin/wt /usr/local/bin/
5353

5454
### Shell Integration (Optional but Recommended)
5555

56-
Add this to your `~/.bashrc` or `~/.zshrc`:
56+
Add this to the **END** of your `~/.bashrc` or `~/.zshrc`:
5757

5858
```bash
5959
source <(wt shellenv)
6060
```
6161

62+
**Note for zsh users:** Place this after `compinit` in your config file.
63+
6264
This enables:
63-
- Automatic `cd` to worktree after `checkout`/`create`/`pr` commands
65+
- Automatic `cd` to worktree after `checkout`/`create`/`pr`/`mr` commands
6466
- Tab completion for commands and branch names
6567

6668
## Usage

main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,13 @@ var shellenvCmd = &cobra.Command{
400400
Short: "Output shell function for auto-cd (source this)",
401401
Long: `Output shell integration code for automatic directory navigation.
402402
403-
Add this to your ~/.bashrc or ~/.zshrc:
403+
Add this to the END of your ~/.bashrc or ~/.zshrc:
404404
source <(wt shellenv)
405405
406+
Note: For zsh, place this AFTER compinit to enable tab completion.
407+
406408
This enables:
407-
- Automatic cd to worktree after checkout/create/pr commands
409+
- Automatic cd to worktree after checkout/create/pr/mr commands
408410
- Tab completion for commands and branch names`,
409411
Run: func(cmd *cobra.Command, args []string) {
410412
fmt.Print(`wt() {
@@ -477,10 +479,7 @@ if [ -n "$ZSH_VERSION" ]; then
477479
esac
478480
fi
479481
}
480-
# Only set up completion if compdef is available (after compinit)
481-
if (( $+functions[compdef] )); then
482-
compdef _wt_complete_zsh wt
483-
fi
482+
compdef _wt_complete_zsh wt
484483
fi
485484
`)
486485
},

0 commit comments

Comments
 (0)