This is a toy project that I play with. Its main purpose is to help me learn Zig. I also needed a simple git worktree tool.
It's been tried and somewhat works in Linux, MacOS and Windows 10.
To build it you need:
- zig version 0.11.0 or newer
- libgit2.
- on Linux - use you package manager
- on MacOS -
brew install libgit2
- on Windows - I build libgit2 from source and put header files in
./deps/include/
and lib file in./deps/lib/
Key bindings are hard-coded in the source:
k
- upj
- downa
- add new worktree from local branchd
- delete worktreeq
orESC
- quit/backEnter
orSpace
- select itemr
- toggle remote/local branch list
The location of the chosen worktree's folder is written in a file named zig-worktree.path
within the TEMP
directory.
I have the following in my bash startup script:
function gw() {
path-to/zig-worktree
if [ $? -eq 0 ]; then
cd $(</tmp/zig-worktree.path)
fi
}
and for powershell
Function gw {
path-to\zig-worktree.exe
if ($LastExitCode -eq 0) {
cd $(Get-Content -Path $env:TEMP\zig-worktree.path -Raw)
}
}