Simplify netty worktree commands

Collapse the netty worktree helpers into wt create/remove/prune, keep wt-create as a thin wrapper, and drop the standalone wt-path command.

Also make the netty zsh wrappers handle cd-only behavior for wtc and wt remove.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Harivansh Rathi 2026-03-30 18:36:50 +00:00
parent 29359546aa
commit bc47e44ddb
5 changed files with 218 additions and 64 deletions

View file

@ -9,6 +9,26 @@ in {
home.packages = builtins.attrValues customScripts.nettyPackages;
programs.zsh.initContent = lib.mkAfter ''
wt() {
if [[ "''${1:-}" == remove ]]; then
local current_worktree_root common_git_dir main_repo_root
current_worktree_root=$(git rev-parse --show-toplevel 2>/dev/null) || {
command wt "$@"
return
}
common_git_dir=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) || return
main_repo_root=$(cd "''${common_git_dir}/.." && pwd -P) || return
command wt "$@" || return
cd -- "$main_repo_root" || return
return
fi
command wt "$@"
}
wtc() {
if [[ $# -ne 1 ]]; then
printf 'usage: wtc <worktree-name>\n' >&2
@ -16,7 +36,7 @@ in {
fi
local worktree_path
worktree_path=$(command wt-create "$1") || return
worktree_path=$(wt create "$1") || return
cd -- "$worktree_path" || return
}
'';