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
|
# (C) 2016 magicant
# Completion script for the "git-worktree" command.
# Supports Git 2.7.0.
function completion/git-worktree {
WORDS=(git worktree "${WORDS[2,-1]}")
command -f completion//reexecute
}
function completion/git::worktree:arg
if [ ${WORDS[#]} -le 1 ]; then
complete -P "$PREFIX" add prune list
else
WORDS=("${WORDS[2,-1]}")
if command -vf "completion/git::worktree:${WORDS[1]}:arg" >/dev/null 2>&1; then
command -f "completion/git::worktree:${WORDS[1]}:arg"
fi
fi
function completion/git::worktree:add:arg {
OPTIONS=( #>#
"B:; create or reset a new branch and check it out"
"b:; create a new branch and check it out"
"--detach; leave HEAD in detached head state"
"f --force; allow multiple working trees for single branch"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Bb])
command -f completion/git::completeref --branches
;;
('')
command -f completion//getoperands
case ${WORDS[#]} in
(0)
complete -P "$PREFIX" -S / -T -d
;;
(1)
command -f completion/git::completeref
;;
esac
;;
esac
}
function completion/git::worktree:prune:arg {
OPTIONS=( #>#
"--expire:; specify age of working trees to remove"
"n --dry-run; don't remove any working trees"
"v --verbose; report removed working trees"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--expire)
# TODO complete date
;;
esac
}
function completion/git::worktree:list:arg {
OPTIONS=( #>#
"--porcelain; print in the machine-friendly format"
) #<#
command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 noet:
|