-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-pool-completion.zsh
More file actions
executable file
·34 lines (31 loc) · 1.27 KB
/
Copy pathgit-pool-completion.zsh
File metadata and controls
executable file
·34 lines (31 loc) · 1.27 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
# git-pool-completion.zsh
#
# Zsh completion for git-object-pool wrapper commands.
#
# Usage: add the following line to ~/.zshrc:
# source ~/Work/git-object-pool/git-pool-completion.zsh
#
# This registers a _git-migrate completion function and hooks it into zsh's
# git completion so that:
# git migrate <Tab> -> --recursive -r
# Ensure compinit has been called.
autoload -Uz compinit
if [[ -z "$_comp_dumpfile" ]]; then
compinit -C
fi
# Hook into zsh git completion: define _git-migrate so that the built-in
# _git dispatcher finds it automatically when the subcommand is "migrate".
_git-migrate () {
_arguments -C \
'(-r --recursive)'{-r,--recursive}'[also migrate initialized submodules]' \
&& return 0
}
# Register "migrate" as a known git subcommand for zsh's _git dispatcher.
# The zsh git completion looks up _git-<subcommand> automatically, but we
# also need "migrate" to appear in the subcommand list.
# We achieve this by wrapping __git_builtin_commands / zstyle if the hook
# point exists, otherwise fall back to a minimal compdef.
if (( $+functions[_git] )); then
# zsh-shipped _git (from git-completion.zsh) uses zstyle user-commands.
zstyle ':completion:*:git:*' user-commands migrate:'migrate existing repo into git object pool'
fi