-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathgtr.bash
More file actions
156 lines (150 loc) · 5.9 KB
/
gtr.bash
File metadata and controls
156 lines (150 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
# AUTO-GENERATED by scripts/generate-completions.sh — DO NOT EDIT MANUALLY
# Re-generate with: ./scripts/generate-completions.sh
#
# Bash completion for git gtr
#
# Prerequisites:
# - bash-completion v2+ must be installed
# - Git's bash completion must be enabled
#
# This completion integrates with git's completion system by defining a _git_<subcommand>
# function, which git's completion framework automatically discovers and calls when
# completing "git gtr ..." commands.
#
# Installation:
# Add to your ~/.bashrc:
# source /path/to/git-worktree-runner/completions/gtr.bash
_git_gtr() {
local cur prev words cword
_init_completion || return
# words array for git subcommand: [git, gtr, <actual_command>, ...]
# cword is the index of current word being completed
# If we're completing the first argument after 'git gtr'
if [ "$cword" -eq 2 ]; then
COMPREPLY=($(compgen -W "new go run copy editor ai rm mv rename ls list clean doctor adapter config completion init trust help version" -- "$cur"))
return 0
fi
local cmd="${words[2]}"
# Commands that take branch names or '1' for main repo
case "$cmd" in
go|run|rm|mv|rename)
if [ "$cword" -eq 3 ]; then
# Complete with branch names and special ID '1' for main repo
local branches all_options
branches=$(git branch --format='%(refname:short)' 2>/dev/null || true)
all_options="1 $branches"
COMPREPLY=($(compgen -W "$all_options" -- "$cur"))
elif [[ "$cur" == -* ]]; then
case "$cmd" in
rm)
COMPREPLY=($(compgen -W "--delete-branch --force --yes" -- "$cur"))
;;
mv|rename)
COMPREPLY=($(compgen -W "--force --yes" -- "$cur"))
;;
esac
fi
;;
editor)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--editor" -- "$cur"))
elif [ "$prev" = "--editor" ]; then
COMPREPLY=($(compgen -W "antigravity atom cursor emacs idea nano none nvim pycharm sublime vim vscode webstorm zed" -- "$cur"))
else
local branches all_options
branches=$(git branch --format='%(refname:short)' 2>/dev/null || true)
all_options="1 $branches"
COMPREPLY=($(compgen -W "$all_options" -- "$cur"))
fi
;;
ai)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--ai" -- "$cur"))
elif [ "$prev" = "--ai" ]; then
COMPREPLY=($(compgen -W "aider auggie claude codex continue copilot cursor gemini none opencode" -- "$cur"))
else
local branches all_options
branches=$(git branch --format='%(refname:short)' 2>/dev/null || true)
all_options="1 $branches"
COMPREPLY=($(compgen -W "$all_options" -- "$cur"))
fi
;;
ls|list)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--porcelain" -- "$cur"))
fi
;;
clean)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--merged --yes -y --dry-run -n --force -f" -- "$cur"))
fi
;;
copy)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "-n --dry-run -a --all --from" -- "$cur"))
else
# Complete with branch names and special ID '1' for main repo
local branches all_options
branches=$(git branch --format='%(refname:short)' 2>/dev/null || true)
all_options="1 $branches"
COMPREPLY=($(compgen -W "$all_options" -- "$cur"))
fi
;;
new)
# Complete flags
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--from --from-current --track --no-copy --no-fetch --no-hooks --force --name --folder --yes --editor -e --ai -a" -- "$cur"))
elif [ "$prev" = "--track" ]; then
COMPREPLY=($(compgen -W "auto remote local none" -- "$cur"))
fi
;;
completion)
# Complete with shell names
if [ "$cword" -eq 3 ]; then
COMPREPLY=($(compgen -W "bash zsh fish" -- "$cur"))
fi
;;
init)
if [ "$cword" -eq 3 ]; then
COMPREPLY=($(compgen -W "bash zsh fish" -- "$cur"))
elif [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--as" -- "$cur"))
fi
;;
config)
# Find action by scanning all config args (handles flexible flag positioning)
local config_action=""
local i
for (( i=3; i < cword; i++ )); do
case "${words[i]}" in
list|get|set|add|unset) config_action="${words[i]}" ;;
esac
done
if [ -z "$config_action" ]; then
# Still need to complete action or scope
COMPREPLY=($(compgen -W "list get set add unset --local --global --system" -- "$cur"))
else
# Have action, complete based on it
case "$config_action" in
list|get)
# Read operations support all scopes including --system
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--local --global --system" -- "$cur"))
else
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
fi
;;
set|add|unset)
# Write operations only support --local and --global (--system requires root)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--local --global" -- "$cur"))
else
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
fi
;;
esac
fi
;;
esac
}