Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Remove fish-functions directory and contents
Maximilian Roosa4bb1fac224d
diff --git a/fish-functions/README.md b/fish-functions/README.mddeleted file mode 100644index 30a37117a..000000000--- a/fish-functions/README.md+++ /dev/null@@ -1,4 +0,0 @@-# Reference Fish Functions--These fish functions are reference implementations showing the prior work that inspired the Rust `wt` tool.-They are not part of the main project and have external dependencies on other fish functions not included here.diff --git a/fish-functions/git-llm-message.fish b/fish-functions/git-llm-message.fishdeleted file mode 100644index fbd0a25f9..000000000--- a/fish-functions/git-llm-message.fish+++ /dev/null@@ -1,149 +0,0 @@-function git-llm-message -d "Generate a commit message using LLM from diff and provided custom instruction"- # This function uses an XML format to structure data for the LLM:- # - <git-info> contains branch and recent commit metadata- # - <git-diff> contains the staged changes- # The LLM uses this structured format to generate a well-formatted commit message.-- argparse debug -- $argv- or return # Exit if argparse finds an invalid option-- # Show informative message- set files_count (git diff --cached --name-only | count)- set stat_summary (git diff --cached --shortstat)-- # IMPORTANT: Using inline color codes in echo statements that are already- # redirected to stderr ensures that color codes never contaminate stdout- echo (set_color cyan)"π Processing $files_count files. $stat_summary. Generating commit message..."(set_color normal) >&2-- # Create a temporary file that will be automatically cleaned up when the function exits- set --local input_file (mktemp)-- # Ensure temp file is removed when function exits (unless --debug is passed)- if set -q _flag_debug- # When debugging, tell the user where to find the temp file- echo (set_color -d)"π¬ === Debug: Temporary file will be preserved at: $input_file ==="(set_color normal) >&2- else- function __cleanup --on-event fish_exit --inherit-variable input_file- rm -f $input_file- end- end-- # Set default system instruction if empty- # $argv now contains non-option arguments after argparse processes them.- set --local actual_system_instruction- if test (count $argv) -gt 0- set actual_system_instruction $argv[1] # Use the first non-option arg as system instruction- end- set --local user_instruction (test -n "$actual_system_instruction" && echo "$actual_system_instruction" || echo "Write a concise, clear git commit message based on the provided diff.")-- # ----- Prepare LLM Input File (Instructions + Git Info + Diff) ------- # Write detailed instructions (formerly part of system prompt) to input_file- printf "%s\n" "Format-- First line: <50 chars, present tense, describes WHAT and WHY (not HOW).-- Blank line after first line.-- Optional details with proper line breaks explaining context. Commits with more substantial changes should have more details.-- Return ONLY the formatted message without quotes, code blocks, or preamble.--Style-- Do not give normative statements or otherwise speculate on why the change was made.-- Broadly match the style of the previous commit messages.- - For example, if they're in conventional commit format, use conventional commits; if they're not, don't use conventional commits.--The context contains:-- <git-diff> with the staged changes. This is the ONLY content you should base your message on.-- <git-info> with branch name and recent commit message titles for style reference ONLY. DO NOT use their content to inform your message.------The following is the context for your task:-----" >$input_file-- # printf "<git-diff>\n```diff" >>$input_file- printf "<git-diff>\n```" >>$input_file- git --no-pager diff --staged >>$input_file- printf "\n```\n</git-diff>\n" >>$input_file-- # Add git context information- printf "<git-info>\n" >>$input_file-- # Try to get current branch name- set current_branch_name (git rev-parse --abbrev-ref HEAD 2>/dev/null)- if test $status -eq 0; and test -n "$current_branch_name"- printf " <current-branch>%s</current-branch>\n" $current_branch_name >>$input_file- end-- # Try to get recent commit messages- set recent_commits_list (git log --pretty='format:%s' -n 5 --no-merges 2>/dev/null)- if test $status -eq 0; and test (count $recent_commits_list) -gt 0- printf " <previous-commit-message-titles>\n" >>$input_file- for commit_msg in $recent_commits_list- printf " <previous-commit-message-title>%s</previous-commit-message-title>\n" $commit_msg >>$input_file- end- printf " </previous-commit-message-titles>\n" >>$input_file- end-- printf "</git-info>\n\n" >>$input_file-- # Debug output if requested- if set -q _flag_debug- set input_size (stat -f %z $input_file)-- echo (set_color -d)"π¬ === Debug: Temporary Files ==="(set_color normal) >&2- echo "π¬ Input file (instructions + git info + diff): $input_file ($input_size bytes)" >&2- echo (set_color -d)"π¬ === Debug: System Instruction (passed directly to LLM) ==="(set_color normal) >&2- echo "π¬ $user_instruction" >&2- echo (set_color -d)"π¬ === Debug: Input File ==="(set_color normal) >&2- cat $input_file >&2- end-- # Execute the command (will be traced if in debug mode)- # Enable command tracing if debug mode is active- if set -q _flag_debug- echo (set_color -d)"π¬ === Debug: Executing LLM Command ==="(set_color normal) >&2- # Set local fish_trace that will automatically go out of scope- set -l fish_trace 1- end-- # Use different LLM configurations based on the OS- switch (uname)- case Darwin- # macOS-specific model and settings- cat $input_file | llm prompt -m gemini-2.5-flash \- -o temperature 0 \- -o google_search 0 \- -o thinking_budget 0 \- --no-log \- --system "$user_instruction" \- | read -z msg \- || return 1- case Linux '*'- # Linux and any other OS uses default configs- cat $input_file | llm prompt \- --no-log \- --system "$user_instruction" \- | read -z msg \- || return 1- end-- # Show generated message to user with colors- # Keep all color codes on stderr so they never contaminate stdout- echo (set_color green)"π Generated message:"(set_color normal) >&2-- # Display first line in bold- set -l all_lines (string split \n -- "$msg")- set -l first_line $all_lines[1]- echo (set_color --bold)"$first_line"(set_color normal) >&2-- # Display the rest if it exists (preserving all formatting)- if test (count $all_lines) -gt 1- set -l remaining_lines $all_lines[2..]- printf "%s\n" $remaining_lines >&2- end- echo "" >&2-- # Return just the message to stdout for piping to other tools- # No color code cleanup needed because we never let them touch stdout- # Use echo to preserve newlines properly- echo -n "$msg"-enddiff --git a/fish-functions/git-squash.fish b/fish-functions/git-squash.fishdeleted file mode 100644index 88bfbadb8..000000000--- a/fish-functions/git-squash.fish+++ /dev/null@@ -1,124 +0,0 @@-function git-squash -d "Squash all commits since branching from specified branch (default: main)"- argparse -n git-squash 'r/rebase' 'A/all' -- $argv- or return 1-- # Get target branch - use argument or default branch- set -l target_branch- if test (count $argv) -gt 0- set target_branch $argv[1]- else- set target_branch (git default-branch)- if test -z "$target_branch"- echo (set_color red)"β Failed to determine default branch"(set_color normal) >&2- return 1- end- end-- # Get merge base- set -l merge_base (git merge-base HEAD "$target_branch")- if test -z "$merge_base"- echo (set_color red)"β Failed to find merge base with "(set_color red --bold)"$target_branch"(set_color normal) >&2- return 1- end-- # Get current branch name for context- set -l current_branch (git rev-parse --abbrev-ref HEAD)- if test -z "$current_branch"- echo (set_color red)"β Failed to determine current branch"(set_color normal) >&2- return 1- end-- # Check if there are any commits to squash- set -l commit_count (git rev-list --count "$merge_base..HEAD")-- # Check if we have staged changes- set -l has_staged_changes 0- if not git diff --cached --quiet --exit-code- set has_staged_changes 1- end-- # Check if we have unstaged changes- set -l has_unstaged_changes 0- if not git diff --quiet --exit-code- set has_unstaged_changes 1- end-- # Handle -A flag to add all changes- if set -ql _flag_all; and test "$has_unstaged_changes" -eq 1- echo (set_color yellow)"π‘ Adding all changes (including unstaged)"(set_color normal) >&2- git add -A- or begin- echo (set_color red)"β Failed to add all changes"(set_color normal) >&2- return 1- end- # After adding, everything is staged- set has_staged_changes 1- set has_unstaged_changes 0- end-- # Handle different squashing scenarios- if test "$commit_count" -eq 0; and test "$has_staged_changes" -eq 0- # No commits and no staged changes - nothing to squash (but might still rebase)- echo (set_color -d)"π¬ No commits to squash - already at merge base"(set_color normal) >&2-- else if test "$commit_count" -eq 0; and test "$has_staged_changes" -eq 1- # Just staged changes, no commits - delegate to git-commit-llm- git-commit-llm- or return 1-- else if test "$commit_count" -eq 1; and test "$has_staged_changes" -eq 0- # Single commit, no staged changes - nothing to do- echo (set_color -d)"π¬ Only 1 commit since "(set_color -d --bold)"$target_branch"(set_color normal -d)" - no squashing needed"(set_color normal) >&2-- else- # One or more commits (possibly with staged changes) - squash them all together- if test "$commit_count" -eq 1; and test "$has_staged_changes" -eq 1- echo (set_color cyan)"π Amending staged changes into the existing commit"(set_color normal) >&2- end-- # Get commit context before resetting- set -l commit_context (__git_build_commit_context "$merge_base..HEAD")-- # Reset to the merge base (this stages all the changes)- git reset --soft $merge_base- or begin- echo (set_color red)"β Failed to reset to merge base"(set_color normal) >&2- return 1- end-- # Generate commit message from the staged changes- set -l commit_message- printf "Squashing commits on branch '%s' since %s\n\n%s" "$current_branch" "$target_branch" "$commit_context" | \- git-llm-message "Generate a commit message that combines these changes into one cohesive message." | \- read -z commit_message- or begin- echo (set_color red)"β Failed to generate commit message"(set_color normal) >&2- return 1- end-- # Commit with the generated message- printf "%s\n\nCo-authored-by: Claude <[email protected]>\n" "$commit_message" | git commit -F -- or begin- echo (set_color red)"β Failed to create commit"(set_color normal) >&2- return 1- end-- if test "$commit_count" -ne 1; or test "$has_staged_changes" -ne 1- echo (set_color green)"β Successfully squashed $commit_count commit(s) into one"(set_color normal) >&2- end- end-- # Rebase if requested (happens for both single and multiple commits)- if set -ql _flag_rebase- # Check if we're already up to date with target branch- if git merge-base --is-ancestor "$target_branch" HEAD- echo (set_color -d)"π¬ Already up to date with "(set_color -d --bold)"$target_branch"(set_color normal -d)" "(set_color normal) >&2- else- echo (set_color cyan)"π Rebasing onto "(set_color cyan --bold)"$target_branch"(set_color normal)(set_color cyan)"..."(set_color normal) >&2- if not git rebase $target_branch- echo (set_color red)"β Failed to rebase onto "(set_color red --bold)"$target_branch"(set_color normal) >&2- return 1- end- end- end-enddiff --git a/fish-functions/git-worktree-finish.fish b/fish-functions/git-worktree-finish.fishdeleted file mode 100644index c7aab3ab3..000000000--- a/fish-functions/git-worktree-finish.fish+++ /dev/null@@ -1,51 +0,0 @@-function git-worktree-finish -d "Finish work on a git worktree or branch without merging"-- # Save current state early, before any operations that might fail- set branch (git branch --show-current)- set default_branch (git default-branch)- set worktree_root (git rev-parse --show-toplevel)- set git_dir (git rev-parse --git-dir)- set common_dir (git rev-parse --git-common-dir)-- # Check for uncommitted changes (staged, unstaged, and untracked)- if __git_is_dirty- git-commit-llm || return 1- end-- # Skip this message if we're in a worktree - we'll have a more specific message later- if test "$git_dir" = "$common_dir"- # Only show branch transition if we're not in a worktree- echo (set_color cyan)"π Branch: "(set_color cyan --bold)"$branch"(set_color normal)(set_color cyan)" β "(set_color cyan --bold)"$default_branch"(set_color normal)(set_color cyan)" "(set_color normal) >&2- end-- # Skip if already on default branch AND not in a worktree- if test "$branch" = "$default_branch" -a "$git_dir" = "$common_dir"- echo (set_color green)"β Already on default branch"(set_color normal) >&2- return 0- end-- # Move back to primary worktree and remove worktree- if test "$git_dir" != "$common_dir"- # In worktree: go to primary worktree, remove worktree- # Navigate to the primary worktree directory (parent of .git)- set -l primary_worktree_dir (dirname $common_dir)- # Get the branch in the primary worktree- set -l primary_branch (git -C "$primary_worktree_dir" branch --show-current)- echo (set_color cyan)"π Moving from $branch worktree to primary at $primary_worktree_dir on $primary_branch"(set_color normal) >&2- cd "$primary_worktree_dir"-- echo (set_color cyan)"π Removing worktree at $worktree_root in background..."(set_color normal) >&2- # Remove worktree in background to avoid waiting- git worktree remove "$worktree_root" </dev/null >/dev/null 2>&1 &- disown 2>/dev/null- else- # Regular branch with available default branch, switch if needed- if test "$branch" != "$default_branch"- echo (set_color cyan)"π Switching to $default_branch"(set_color normal) >&2- git switch $default_branch- end- end-- # Return the branch name as status so it can be captured- return 0-enddiff --git a/fish-functions/git-worktree-llm.fish b/fish-functions/git-worktree-llm.fishdeleted file mode 100644index b83d8aad2..000000000--- a/fish-functions/git-worktree-llm.fish+++ /dev/null@@ -1,9 +0,0 @@-function git-worktree-llm -d "Create a git worktree and start claude"- # Create the worktree, then run setup in background and start claude- if git-worktree-switch --create $argv- task setup-worktree </dev/null >/dev/null 2>&1 & disown- task install </dev/null >/dev/null 2>&1 & disown- echo (set_color brblack)"π Running setup in background..."(set_color normal) >&2- claude- end-enddiff --git a/fish-functions/git-worktree-merge.fish b/fish-functions/git-worktree-merge.fishdeleted file mode 100644index b9e482fa4..000000000--- a/fish-functions/git-worktree-merge.fish+++ /dev/null@@ -1,104 +0,0 @@-function git-worktree-merge -d "Finish worktree and merge branch into target branch (default: main)"- argparse -n git-worktree-merge s/squash k/no-remove -- $argv- or return 1-- # Get current branch- set -l branch (git branch --show-current)- if test -z "$branch"- echo (set_color red)"β Failed to determine current branch"(set_color normal) >&2- return 1- end-- # Get target branch- set -l target_branch $argv[1]- if test -z "$target_branch"- set target_branch (git default-branch)- or return 1- end-- # Handle uncommitted changes (including untracked files)- if __git_is_dirty- # Warn if user had staged changes that will be mixed in- if not git diff --cached --quiet --exit-code- echo (set_color yellow)"π‘ Note: Adding all changes (you had some staged changes)"(set_color normal) >&2- end-- if set -ql _flag_squash- # When squashing, just stage changes - they'll be included in the squash- git add .- else- # When not squashing, commit changes normally- git add .- # Check if there's actually anything to commit after staging- if not git diff --cached --quiet --exit-code- echo (set_color cyan)"π Committing uncommitted changes..."(set_color normal) >&2- if not git-commit-llm- echo (set_color red)"β Failed to commit changes"(set_color normal) >&2- return 1- end- end- end- end-- # Check primary worktree state if we're in a worktree- set -l git_dir (git rev-parse --git-dir)- set -l common_dir (git rev-parse --git-common-dir)-- if test "$git_dir" != "$common_dir"- set -l primary_worktree_dir (dirname $common_dir)-- if set -l operation (fish -c "cd '$primary_worktree_dir' && git-is-operation-in-progress")- echo (set_color red)"β Primary worktree has a $operation in progress"(set_color normal) >&2- git -C "$primary_worktree_dir" status --short- return 1- end- end-- # Prepare commits- if set -ql _flag_squash- if not git-squash --rebase "$target_branch"- echo (set_color red)"β Failed to squash and rebase commits"(set_color normal) >&2- return 1- end- else- if not git rebase "$target_branch"- echo (set_color red)"β Failed to rebase onto "(set_color red --bold)"$target_branch"(set_color normal)(set_color red)" "(set_color normal) >&2- return 1- end- end-- # Check if we're already on the target branch- if test "$branch" = "$target_branch"- echo (set_color -d)"π¬ Already on "(set_color -d --bold)"$target_branch"(set_color normal -d)", nothing to merge"(set_color normal) >&2- return 0- end-- # Fast-forward target branch- if not git-worktree-push "$target_branch"- echo (set_color red)"β Failed to fast-forward "(set_color red --bold)"$target_branch"(set_color normal)(set_color red)" "(set_color normal) >&2- return 1- end-- # Finish worktree unless --no-remove was specified- if not set -q _flag_no_remove- # Always finish the current worktree first (handles cleanup)- if not git-worktree-finish- echo (set_color red)"β Failed to finish worktree"(set_color normal) >&2- return 1- end-- # Now try to switch to the target branch- set -l current_branch (git branch --show-current)- if test "$current_branch" != "$target_branch"- echo (set_color cyan)"π Switching to $target_branch..."(set_color normal) >&2- # Try regular switch first- if not git switch "$target_branch" 2>/dev/null- # If switch fails, target branch is likely in another worktree- # Use git-worktree-switch to handle that case- git-worktree-switch "$target_branch"- end- end- else- echo (set_color green)"β Branch merged to $target_branch (worktree preserved)"(set_color normal) >&2- end-enddiff --git a/fish-functions/git-worktree-push.fish b/fish-functions/git-worktree-push.fishdeleted file mode 100644index a84f97938..000000000--- a/fish-functions/git-worktree-push.fish+++ /dev/null@@ -1,132 +0,0 @@-function git-worktree-push -d "Fast-forward push to a branch from another worktree"- argparse -n git-worktree-push 'allow-merge-commits' -- $argv- or return 1-- set -l target_branch $argv[1]- test -z "$target_branch"; and set target_branch (git default-branch)-- # Check if it's a fast-forward- if not git merge-base --is-ancestor $target_branch HEAD- echo (set_color red)"β Not a fast-forward from "(set_color red --bold)"$target_branch"(set_color normal)(set_color red)" to HEAD"(set_color normal) >&2- echo (set_color -d)"π‘ The target branch has commits not in your current branch. Consider 'git pull' or 'git rebase'"(set_color normal) >&2- return 1- end-- # Check for merge commits unless --allow-merge-commits is specified- if not set -q _flag_allow_merge_commits- set -l merge_commits (git rev-list --merges $target_branch..HEAD)- if test -n "$merge_commits"- set -l merge_count (count $merge_commits)- echo (set_color red)"β Found $merge_count merge commit(s) in the push range:"(set_color normal) >&2- for commit in $merge_commits- echo " "(git log --oneline -n1 $commit) >&2- end- echo (set_color yellow)"π‘ Use --allow-merge-commits to push non-linear history"(set_color normal) >&2- return 1- end- end-- # Get the git common directory (the actual .git folder)- set -l git_common_dir (git rev-parse --git-common-dir)-- # One-time setup check: ensure receive.denyCurrentBranch is configured- set -l deny_config (git config receive.denyCurrentBranch)- if test "$deny_config" != "updateInstead"- git config receive.denyCurrentBranch updateInstead- end-- # Check if target branch is checked out in any worktree- set -l worktree_path ""- set -l current_worktree ""- for line in (git worktree list --porcelain | string split "\n")- if string match -q "worktree *" $line- set current_worktree (string replace "worktree " "" $line)- else if string match -q "branch refs/heads/$target_branch" $line- set worktree_path $current_worktree- break- end- end-- # Check if we have a target worktree- set -l stash_created 0- if test -n "$worktree_path"- # Check for changes in the target worktree- set -l has_changes (git -C "$worktree_path" status --porcelain)-- if test -n "$has_changes"- # Check for file overlap between push changes and working tree changes- set -l push_files (git diff --name-only $target_branch..HEAD)- set -l worktree_files (git -C "$worktree_path" status --porcelain | string match -r '^\s*[MADRCU?!]\s+(.*)$' | string replace -r '^\s*[MADRCU?!]\s+' '')-- # Find overlapping files- set -l overlapping_files- for file in $push_files- if contains -- $file $worktree_files- set -a overlapping_files $file- end- end-- # If there are overlapping files, always fail- if test (count $overlapping_files) -gt 0- echo (set_color red)"β Cannot push: conflicting uncommitted changes in:"(set_color normal) >&2- for file in $overlapping_files- echo " - $file" >&2- end- echo (set_color -d)"π‘ Commit or stash these changes in $worktree_path first"(set_color normal) >&2- return 1- end-- # No overlapping changes - stash any other changes (including untracked)- echo (set_color cyan)"π Stashing changes in $worktree_path..."(set_color normal) >&2- # Use --include-untracked to stash untracked files too- set -l stash_output (git -C "$worktree_path" stash push --include-untracked -m "git-worktree-push autostash" 2>&1)- if test $status -eq 0- # Check if anything was actually stashed- if not string match -q "No local changes to save" "$stash_output"- set stash_created 1- end- else- echo (set_color red)"β Failed to stash changes"(set_color normal) >&2- return 1- end- end- end-- # Count commits being pushed- set -l commit_count (git rev-list --count $target_branch..HEAD)- set -l commit_text "commit"- if test $commit_count -ne 1- set commit_text "commits"- end-- # Show what will be pushed - graph of commits between target and HEAD- if test "$commit_count" -gt 0- echo (set_color cyan)"π Pushing $commit_count $commit_text to "(set_color cyan --bold)"$target_branch"(set_color normal)(set_color cyan)" @ "(git rev-parse --short HEAD)":"(set_color normal) >&2- echo >&2- # Show graph with decorations, limited to the relevant range- git --no-pager log --graph --oneline --decorate $target_branch..HEAD >&2- echo >&2- else- echo (set_color cyan)"π Pushing to "(set_color cyan --bold)"$target_branch"(set_color normal)(set_color cyan)"..."(set_color normal) >&2- end-- # Perform the push- if not git push "$git_common_dir" HEAD:$target_branch- echo (set_color red)"β Push failed (check git permissions and branch protection)"(set_color normal) >&2-- # Try to restore the stash if we created one- if test $stash_created -eq 1- echo (set_color cyan)"π Restoring stashed changes..."(set_color normal) >&2- git -C "$worktree_path" stash pop --quiet- end- return 1- end-- # Pop the stash if we created one- if test $stash_created -eq 1- echo (set_color cyan)"π Restoring stashed changes..."(set_color normal) >&2- if not git -C "$worktree_path" stash pop --quiet- echo (set_color yellow)"π‘ Failed to restore stash - run 'git stash pop' in $worktree_path"(set_color normal) >&2- end- end-enddiff --git a/fish-functions/git-worktree-switch.fish b/fish-functions/git-worktree-switch.fishdeleted file mode 100644index e9d2f85b4..000000000--- a/fish-functions/git-worktree-switch.fish+++ /dev/null@@ -1,71 +0,0 @@-function git-worktree-switch --description "Switch to a git worktree, creating branch/worktree as needed"- # Parse arguments- argparse -n git-worktree-switch --min-args=1 --max-args=1 'c/create' 'b/base=' -- $argv- or return 1-- set -l branch_name $argv[1]-- # Check for conflicting conditions- if set -q _flag_create; and __git_branch_exists "$branch_name"- echo (set_color red)"β Branch "(set_color red --bold)"$branch_name"(set_color normal)(set_color red)" already exists. Remove --create flag to switch to it."(set_color normal) >&2- return 1- end- # With worktree.guessRemote=true, git will automatically create from remote branches-- # Check if base flag was provided without create flag- if set -q _flag_base; and not set -q _flag_create- echo (set_color yellow)"π‘ Warning: --base flag is only used with --create, ignoring"(set_color normal) >&2- end-- # Check if worktree already exists for this branch- set -l existing_path ""- for line in (string split \n (git worktree list --porcelain | string collect))- if string match -q "worktree *" $line- set existing_path (string replace "worktree " "" $line)- else if string match -q "branch refs/heads/$branch_name" $line- # Worktree already exists for this branch- if test -d "$existing_path"- cd "$existing_path"- return 0- else- echo (set_color yellow)"π‘ Worktree directory missing for "(set_color yellow --bold)"$branch_name"(set_color normal)(set_color yellow)". Run 'git worktree prune' to clean up."(set_color normal) >&2- return 1- end- end- end-- # No existing worktree, create one- set -l git_common_dir (realpath (git rev-parse --git-common-dir))- set -l repo_root (dirname $git_common_dir)- set -l repo_name (basename $repo_root)- set -l parent_dir (dirname $repo_root)- set -l worktree_path "$parent_dir/$repo_name.$branch_name"-- # Create the worktree- set -l success_msg ""- if set -q _flag_create- # Creating new branch- if set -q _flag_base- git worktree add "$worktree_path" -b "$branch_name" "$_flag_base"- else- git worktree add "$worktree_path" -b "$branch_name"- end- set success_msg "β Created new branch and worktree for "- else- # Using existing branch- git worktree add "$worktree_path" "$branch_name"- set success_msg "β Added worktree for existing branch "- end-- # Check if worktree creation succeeded- if test $status -eq 0- echo (set_color green)"$success_msg"(set_color green --bold)"$branch_name"(set_color normal)(set_color green)" at $worktree_path"(set_color normal) >&2- cd "$worktree_path"- else- return 1- end-end--# Completions for this function are defined in ~/.config/fish/completions/git.fish-# They must be there because this function is invoked as "git worktree-switch"-# and Fish loads completions based on the first token (git)