Skip to content

ten4o/zig-worktree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Worktree in Zig

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 - up
  • j - down
  • a - add new worktree from local branch
  • d - delete worktree
  • q or ESC - quit/back
  • Enter or Space - select item
  • r - toggle remote/local branch list

Changing CWD

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)
   }
}

About

Git Worktree in Zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages