Git worktrees in Zellij.
__
| \
__ __ __ ______ ______ | $$ __ __
| \ | \ | \ / \ / \ | $$ / \ | \
| $$ | $$ | $$| $$$$$$\| $$$$$$\| $$_/ $$ \$$
| $$ | $$ | $$| $$ | $$| $$ \$$| $$ $$ | \
| $$_/ $$_/ $$| $$__/ $$| $$ | $$$$$$\ | $$
\$$ $$ $$ \$$ $$| $$ | $$ \$$\ | $$
\$$$$$\$$$$ \$$$$$$ \$$ \$$ \$$__ | $$
| \__/ $$
\$$ $$
\$$$$$$
workj — Git Worktree & Zellij Helper
A simplified way of using Git worktrees with Zellij.
git clone https://github.com/Guilospanck/workj.git
cd workj/
./install.shAfter that, you can run it following Usage section.
Before using it, check if the default configs (/configs/*) make sense for you. If they don't, you can create a ~/.workj/config.cfg file or pass in via the CLI with the -c (or --config-file) option the path to where your custom config is located (check the workj -h to see options and how to use). The valid keys are displayed in /configs/workj_config.cfg.
main_branchis the start point for the new branch (if it doesn't exist). Defaultorigin/main;layoutis the path to the Zellij layout you want to use when starting a newworkj add <branch>command. Defaultconfigs/layout.kdl;no_envs_copy: whether to copy theenvfiles when creating a git worktree.falsemeans that the env files will be copied. Defaultfalse.
Note
If you don't pass a config via the -c/--config-file option, it will check for it at the global level ~/.workj/config.cfg. If the config file doesn't exist there, the default values (the ones inside /configs/*) will be used.
Run workj -h for available commands and docs.
Note
When you run the add command, it creates a new worktree at $PROJECT_ROOT_LEVEL/../${PROJECT_NAME}__worktrees/${BRANCH_NAME} and open a new Zellij tab at that directory with panes based on the layout.kdl file.
Build it:
zig build
# just build
# For release:
zig build -Doptimize=ReleaseSafe
# just releaseRun it:
./zig-out/bin/workj <commmand> <branch_name>Or you can also do both of them in one line:
zig build run -- <command> <branch_name>
# just run <command> <branch>You can run tests with:
zig build test
# just testsBe aware that it will only print to stderr if there is an actual error in the test or if you did use something like std.debug.print.
Optionally, you can also run a specific test file with:
zig test <path_to_test_file>
# zig test src/git_test.zigor all of them:
zig test src/tests.zigNote
Each *_test.zig file you create, you MUST import it in src/tests/index.zig in order for the zig build test command to find it.