How It Works
wit provides plumbing commands that output the current branch name, which can be used in your shell prompt:Bash Integration
Add the following to your~/.bashrc:
Example Output
Zsh Integration
Add the following to your~/.zshrc:
With Oh My Zsh
If you use Oh My Zsh, you can create a custom plugin. Create the file~/.oh-my-zsh/custom/plugins/wit/wit.plugin.zsh:
wit to your plugins in ~/.zshrc:
Advanced: Detached HEAD State
When you checkout a specific commit (detached HEAD state), the branch name won’t be available. You can show the short commit hash instead:Bash (with detached HEAD support)
Zsh (with detached HEAD support)
Advanced: Dirty State Indicator
Show an asterisk when you have uncommitted changes:Bash
Zsh
Performance Tips
The prompt function runs every time you press Enter, so it’s important to keep it fast.
- Use
2>/dev/nullto suppress error messages when not in a wit repository - Avoid multiple wit calls - each command spawns a new process
- Consider caching for very large repositories:
Fish Shell Integration
For Fish shell users, add this to~/.config/fish/functions/fish_prompt.fish:
Starship Integration
If you use Starship, add a custom command to~/.config/starship.toml:
Troubleshooting
Branch not showing in prompt
Branch not showing in prompt
- Make sure you’re inside a wit repository (has a
.witdirectory) - Verify wit is installed and in your PATH:
which wit - Test the command manually:
wit rev-parse --abbrev-ref HEAD
Slow prompt
Slow prompt
If your prompt is slow:
- Make sure you’re not running multiple wit commands in the function
- Consider using the caching approach above
- Check if your repository is very large
Prompt breaks outside wit repositories
Prompt breaks outside wit repositories
Always use
2>/dev/null to suppress errors when not in a wit repository.
The functions above handle this automatically.Next Steps
Commands Reference
Learn all available commands
Configuration
Customize wit behavior