From 2199a791a392919d0ec89f76fbcc807bfa4ec246 Mon Sep 17 00:00:00 2001 From: kuderr Date: Wed, 25 Feb 2026 15:52:57 +0300 Subject: [PATCH] fix: rename local path to wt_path to avoid zsh PATH collision In zsh, `path` is a special variable tied to `PATH`. Declaring `local path` inside a function empties PATH, breaking all commands. Co-Authored-By: Claude Opus 4.6 --- aliases/git-wt.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aliases/git-wt.sh b/aliases/git-wt.sh index 3de4197..6974f0b 100644 --- a/aliases/git-wt.sh +++ b/aliases/git-wt.sh @@ -6,17 +6,17 @@ # cd into a worktree by name # wtcd my-feature wtcd() { - local path - path=$(git wt path "$1" 2>/dev/null) || { echo "error: worktree '$1' not found" >&2; return 1; } - cd "$path" || return 1 + local wt_path + wt_path=$(git wt path "$1" 2>/dev/null) || { echo "error: worktree '$1' not found" >&2; return 1; } + cd "$wt_path" || return 1 } # cd into the origin (main) repo from any worktree # wto wto() { - local path - path=$(git wt origin 2>/dev/null) || { echo "error: not in a git repo" >&2; return 1; } - cd "$path" || return 1 + local wt_path + wt_path=$(git wt origin 2>/dev/null) || { echo "error: not in a git repo" >&2; return 1; } + cd "$wt_path" || return 1 } # Create a new worktree and cd into it @@ -24,16 +24,16 @@ wto() { # wtn (auto-generated name) # wtn -b main hotfix wtn() { - local output line path + local output line wt_path output=$(git wt new "$@") || return 1 echo "$output" while IFS= read -r line; do if [[ "$line" == *"Path:"* ]]; then - read -r path <<< "${line##*Path:}" + read -r wt_path <<< "${line##*Path:}" break fi done <<< "$output" - [[ -n "${path:-}" ]] && cd "$path" || return 1 + [[ -n "${wt_path:-}" ]] && cd "$wt_path" || return 1 } # List worktrees (current repo)