-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathgit-gtr.fish
More file actions
164 lines (148 loc) · 8.99 KB
/
git-gtr.fish
File metadata and controls
164 lines (148 loc) · 8.99 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
157
158
159
160
161
162
163
164
# AUTO-GENERATED by scripts/generate-completions.sh — DO NOT EDIT MANUALLY
# Re-generate with: ./scripts/generate-completions.sh
#
# Fish completion for git gtr
#
# This completion integrates with fish's completion system by registering completions
# for the "git" command with custom predicates that detect "git gtr" usage.
#
# Installation:
# Symlink to fish's completions directory:
# ln -s /path/to/git-worktree-runner/completions/git-gtr.fish ~/.config/fish/completions/
# Then reload fish:
# exec fish
# Helper function to check if we're in 'git gtr' context
function __fish_git_gtr_needs_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 2 -a "$cmd[1]" = "git" -a "$cmd[2]" = "gtr" ]
return 0
end
return 1
end
function __fish_git_gtr_using_command
set -l cmd (commandline -opc)
if [ (count $cmd) -ge 3 -a "$cmd[1]" = "git" -a "$cmd[2]" = "gtr" ]
for i in $argv
if [ "$cmd[3]" = "$i" ]
return 0
end
end
end
return 1
end
# Commands
complete -f -c git -n '__fish_git_gtr_needs_command' -a new -d 'Create a new worktree'
complete -f -c git -n '__fish_git_gtr_needs_command' -a go -d 'Navigate to worktree'
complete -f -c git -n '__fish_git_gtr_needs_command' -a run -d 'Execute command in worktree'
complete -f -c git -n '__fish_git_gtr_needs_command' -a rm -d 'Remove worktree(s)'
complete -f -c git -n '__fish_git_gtr_needs_command' -a mv -d 'Rename worktree and branch'
complete -f -c git -n '__fish_git_gtr_needs_command' -a rename -d 'Rename worktree and branch'
complete -f -c git -n '__fish_git_gtr_needs_command' -a copy -d 'Copy files between worktrees'
complete -f -c git -n '__fish_git_gtr_needs_command' -a editor -d 'Open worktree in editor'
complete -f -c git -n '__fish_git_gtr_needs_command' -a ai -d 'Start AI coding tool'
complete -f -c git -n '__fish_git_gtr_needs_command' -a ls -d 'List all worktrees'
complete -f -c git -n '__fish_git_gtr_needs_command' -a list -d 'List all worktrees'
complete -f -c git -n '__fish_git_gtr_needs_command' -a clean -d 'Remove stale worktrees'
complete -f -c git -n '__fish_git_gtr_needs_command' -a doctor -d 'Health check'
complete -f -c git -n '__fish_git_gtr_needs_command' -a adapter -d 'List available adapters'
complete -f -c git -n '__fish_git_gtr_needs_command' -a config -d 'Manage configuration'
complete -f -c git -n '__fish_git_gtr_needs_command' -a completion -d 'Generate shell completions'
complete -f -c git -n '__fish_git_gtr_using_command completion' -a 'bash zsh fish' -d 'Shell type'
complete -f -c git -n '__fish_git_gtr_needs_command' -a init -d 'Generate shell integration for cd support'
complete -f -c git -n '__fish_git_gtr_using_command init' -a 'bash zsh fish' -d 'Shell type'
complete -c git -n '__fish_git_gtr_using_command init' -l as -d 'Custom function name' -r
complete -f -c git -n '__fish_git_gtr_needs_command' -a trust -d 'Trust .gtrconfig hooks'
complete -f -c git -n '__fish_git_gtr_needs_command' -a version -d 'Show version'
complete -f -c git -n '__fish_git_gtr_needs_command' -a help -d 'Show help'
# New command options
complete -c git -n '__fish_git_gtr_using_command new' -l from -d 'Base ref' -r
complete -c git -n '__fish_git_gtr_using_command new' -l from-current -d 'Create from current branch'
complete -c git -n '__fish_git_gtr_using_command new' -l track -d 'Track mode' -r -a 'auto remote local none'
complete -c git -n '__fish_git_gtr_using_command new' -l no-copy -d 'Skip file copying'
complete -c git -n '__fish_git_gtr_using_command new' -l no-fetch -d 'Skip git fetch'
complete -c git -n '__fish_git_gtr_using_command new' -l no-hooks -d 'Skip post-create hooks'
complete -c git -n '__fish_git_gtr_using_command new' -l force -d 'Allow same branch in multiple worktrees'
complete -c git -n '__fish_git_gtr_using_command new' -l name -d 'Custom folder name suffix' -r
complete -c git -n '__fish_git_gtr_using_command new' -l folder -d 'Custom folder name (replaces default)' -r
complete -c git -n '__fish_git_gtr_using_command new' -l yes -d 'Non-interactive mode'
complete -c git -n '__fish_git_gtr_using_command new' -s e -l editor -d 'Open in editor after creation'
complete -c git -n '__fish_git_gtr_using_command new' -s a -l ai -d 'Start AI tool after creation'
# Remove command options
complete -c git -n '__fish_git_gtr_using_command rm' -l delete-branch -d 'Delete branch'
complete -c git -n '__fish_git_gtr_using_command rm' -l force -d 'Force removal even if worktree has uncommitted changes or untracked files'
complete -c git -n '__fish_git_gtr_using_command rm' -l yes -d 'Non-interactive mode'
# Rename command options
complete -c git -n '__fish_git_gtr_using_command mv' -l force -d 'Force move even if locked'
complete -c git -n '__fish_git_gtr_using_command mv' -l yes -d 'Skip confirmation'
complete -c git -n '__fish_git_gtr_using_command rename' -l force -d 'Force move even if locked'
complete -c git -n '__fish_git_gtr_using_command rename' -l yes -d 'Skip confirmation'
# Copy command options
complete -c git -n '__fish_git_gtr_using_command copy' -s n -l dry-run -d 'Preview without copying'
complete -c git -n '__fish_git_gtr_using_command copy' -s a -l all -d 'Copy to all worktrees'
complete -c git -n '__fish_git_gtr_using_command copy' -l from -d 'Source worktree' -r
# List command options
complete -c git -n '__fish_git_gtr_using_command list' -l porcelain -d 'Machine-readable output'
complete -c git -n '__fish_git_gtr_using_command ls' -l porcelain -d 'Machine-readable output'
# Editor command options
complete -c git -n '__fish_git_gtr_using_command editor' -l editor -d 'Editor to use' -r -a 'antigravity atom cursor emacs idea nano none nvim pycharm sublime vim vscode webstorm zed'
# AI command options
complete -c git -n '__fish_git_gtr_using_command ai' -l ai -d 'AI tool to use' -r -a 'aider auggie claude codex continue copilot cursor gemini none opencode'
# Clean command options
complete -c git -n '__fish_git_gtr_using_command clean' -l merged -d 'Remove worktrees with merged PRs/MRs'
complete -c git -n '__fish_git_gtr_using_command clean' -l yes -d 'Skip confirmation prompts'
complete -c git -n '__fish_git_gtr_using_command clean' -s y -d 'Skip confirmation prompts'
complete -c git -n '__fish_git_gtr_using_command clean' -l dry-run -d 'Show what would be removed'
complete -c git -n '__fish_git_gtr_using_command clean' -s n -d 'Show what would be removed'
complete -c git -n '__fish_git_gtr_using_command clean' -s f -l force -d 'Force removal even if worktree has uncommitted changes or untracked files'
# Config command
complete -f -c git -n '__fish_git_gtr_using_command config' -a 'list get set add unset'
# Helper to check if config action is a read operation (list or get)
function __fish_git_gtr_config_is_read
set -l cmd (commandline -opc)
for i in $cmd
if test "$i" = "list" -o "$i" = "get"
return 0
end
end
return 1
end
# Scope flags for config command
# --local and --global available for all operations
complete -f -c git -n '__fish_git_gtr_using_command config' -l local -d 'Use local git config'
complete -f -c git -n '__fish_git_gtr_using_command config' -l global -d 'Use global git config'
# --system only for read operations (list, get) - write requires root
complete -f -c git -n '__fish_git_gtr_using_command config; and __fish_git_gtr_config_is_read' -l system -d 'Use system git config'
complete -f -c git -n '__fish_git_gtr_using_command config' -a "
gtr.copy.include 'Files to copy'
gtr.copy.exclude 'Files to exclude'
gtr.copy.includeDirs 'Directories to copy (e.g., node_modules)'
gtr.copy.excludeDirs 'Directories to exclude'
gtr.hook.postCreate 'Post-create hook'
gtr.hook.preRemove 'Pre-remove hook (abort on failure)'
gtr.hook.postRemove 'Post-remove hook'
gtr.hook.postCd 'Post-cd hook (shell integration only)'
gtr.editor.default 'Default editor'
gtr.editor.workspace 'Path to workspace file (.code-workspace)'
gtr.ai.default 'Default AI tool'
gtr.worktrees.dir 'Worktrees base directory'
gtr.worktrees.prefix 'Worktree folder prefix'
gtr.defaultBranch 'Default branch'
gtr.provider 'Hosting provider (github, gitlab)'
gtr.ui.color 'Color output mode (auto, always, never)'
"
# Helper function to get branch names and special '1' for main repo
function __gtr_worktree_branches
# Special ID for main repo
echo '1'
# Get branch names
git branch --format='%(refname:short)' 2>/dev/null
end
# Complete branch names for commands that need them
complete -f -c git -n '__fish_git_gtr_using_command go' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command run' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command copy' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command editor' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command ai' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command rm' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command mv' -a '(__gtr_worktree_branches)'
complete -f -c git -n '__fish_git_gtr_using_command rename' -a '(__gtr_worktree_branches)'