Changelog
Installation
Download Binary
Choose the appropriate binary for your platform from the assets below:
Linux (x86_64)
curl -L https://github.com/liamawhite/worktree/releases/download/v0.2.0/worktree_Linux_x86_64.tar.gz | tar xz
chmod +x worktree
sudo mv worktree /usr/local/bin/Linux (ARM64)
curl -L https://github.com/liamawhite/worktree/releases/download/v0.2.0/worktree_Linux_arm64.tar.gz | tar xz
chmod +x worktree
sudo mv worktree /usr/local/bin/macOS (Intel)
curl -L https://github.com/liamawhite/worktree/releases/download/v0.2.0/worktree_Darwin_x86_64.tar.gz | tar xz
chmod +x worktree
sudo mv worktree /usr/local/bin/macOS (Apple Silicon)
curl -L https://github.com/liamawhite/worktree/releases/download/v0.2.0/worktree_Darwin_arm64.tar.gz | tar xz
chmod +x worktree
sudo mv worktree /usr/local/bin/Verify Installation
worktree --versionOptional: Shell Integration for Directory Switching
To enable automatic directory changes when using worktree add and worktree switch commands, add this function to your shell profile:
(~/.bashrc, ~/.bash_profile, ~/.zshrc):
worktree() {
local cmd="$1"
# Commands that should change directory
if [[ "$cmd" == "add" || "$cmd" == "switch" || "$cmd" == "sw" || "$cmd" == "setup" ]]; then
# Capture stderr to look for WT_CHDIR while preserving stdout and interactive TUI
local temp_file
temp_file=$(mktemp)
# Run command with stderr redirected to temp file
command worktree "$@" 2> >(tee "$temp_file" >&2)
local exit_code=$?
# Look for directory change indicator in stderr
local target_dir
target_dir=$(grep "^WT_CHDIR:" "$temp_file" 2>/dev/null | sed 's/^WT_CHDIR://')
# Clean up temp file
rm -f "$temp_file"
# Change directory if target was specified
if [[ -n "$target_dir" && -d "$target_dir" ]]; then
cd "$target_dir" || echo "Warning: Failed to change to directory: $target_dir"
fi
return $exit_code
else
# For all other commands, just run normally
command worktree "$@"
fi
}After adding this function and restarting your shell (or running source ~/.bashrc/source ~/.zshrc), the worktree add, worktree switch, and worktree setup commands will automatically change your current directory to the worktree location.
Verification with Checksums
Download checksums.txt and verify your binary:
sha256sum -c checksums.txtReleased by GoReleaser.