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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
|
# (C) 2011 magicant
# Completion script for the "git-config" command.
# Supports Git 1.7.7.
function completion/git-config {
WORDS=(git config "${WORDS[2,-1]}")
command -f completion//reexecute
}
function completion/git::config:arg {
OPTIONS=( #>#
"--add; add a new line to the option value"
"--bool; ensure the option value is a boolean"
"--bool-or-int; ensure the option value is a boolean or integer"
"e --edit; start an editor to edit the config file"
"f: --file:; specify the config file path"
"--get; print an option value"
"--get-all; print one or more option values"
"--get-color; print ANSI color escape sequence"
"--get-colorbool; check if output should be colored"
"--get-regexp; print options whose keys match the specified regular expression"
"--global; get or set the global options"
"--int; ensure the option value is an integer"
"l --list; print all options set"
"z --null; print a null byte after each key-value pair"
"--path; perform tilde expansion when printing option values"
"--remove-section; remove a section"
"--rename-section; rename a section"
"--replace-all; replace all matching values"
"--system; get or set the system-wide options"
"--unset; remove (part of) an option"
"--unset-all; remove (all matching parts of) an option"
) #<#
command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(f|--file)
complete -P "$PREFIX" -f
;;
('')
command -f completion//git::completeoptionname
;;
esac
}
function completion//git::completeoptionname {
typeset usesuffix= suffix
if [ $# -gt 0 ]; then
usesuffix=true suffix=$1
fi
typeset word="${TARGETWORD#"$PREFIX"}"
# complete existing settings
typeset word2 prefix2 name value
word2="${word##*.}"
prefix2="${TARGETWORD%"$word2"}"
while read -r name value; do
name=${name#"$prefix2"}
case $name in
(*.*)
name=${name%%.*}
complete -P "$prefix2" -S . -T -- "$name"
;;
(*)
complete -P "$prefix2" ${usesuffix:+-S "$suffix" -T} -- \
"$name"
;;
esac
done 2>/dev/null <(git config --get-regexp "${word//./'\.'}.*")
case $word in
(add.*)
PREFIX=${PREFIX}add. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
ignoreErrors
;; #<<#
(advice.*)
PREFIX=${PREFIX}advice. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
commitBeforeMerge detachedHead implicitIdentity\
pushNonFastForward resolveConflict statusHints
;; #<<#
(alias.*)
PREFIX=${PREFIX}alias. #>>#
command -f completion/git::completealias ${usesuffix+"$suffix"}
;;
(am.*)
PREFIX=${PREFIX}am. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
keepcr
;; #<<#
(apply.*)
PREFIX=${PREFIX}apply. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
ignorewhitespace whitespace
;; #<<#
(branch.*.*)
word=${word#branch.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
merge mergeoptions rebase remote
;; #<<#
(branch.*)
PREFIX=${PREFIX}branch. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autosetupmerge autosetuprebase
#<<#
command -f completion/git::completeref \
abbrprefixes=refs/heads/ dontcompletefull=true \
suffix=. --branches
;;
(browser.*.*|difftool.*.*|man.*.*)
word=${word#*.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
cmd path
;; #<<#
(clean.*)
PREFIX=${PREFIX}clean. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
requireForce
;; #<<#
(color.branch.*)
PREFIX=${PREFIX}color.branch. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
current local plain remote
;; #<<#
(color.diff.*)
PREFIX=${PREFIX}color.diff. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
commit frag func meta new old plain whitespace
;; #<<#
(color.decorate.*)
PREFIX=${PREFIX}color.decorate. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
branch HEAD remoteBranch stash tag
;; #<<#
(color.grep.*)
PREFIX=${PREFIX}color.grep. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
context filename function linenumber match \
selected separator
;; #<<#
(color.interactive.*)
PREFIX=${PREFIX}color.interactive. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
error header help prompt
;; #<<#
(color.status.*)
PREFIX=${PREFIX}color.status. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
added branch changed header nobranch untracked \
updated
;; #<<#
(color.*)
PREFIX=${PREFIX}color. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
branch diff grep interactive pager showbranch \
status ui
#<<#
complete -P "$PREFIX" -S . -T -- \
branch diff decorate grep interactive status
;;
(commit.*)
PREFIX=${PREFIX}commit. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
status template
;; #<<#
(core.*)
PREFIX=${PREFIX}core. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
abbrev askpass attributesfile autocrlf bare \
bigFileThreshold compression createObject \
deltaBaseCacheLimit editor eol excludesfile \
fileMode fsyncobjectfiles gitProxy \
ignoreCygwinFSTricks ignoreStat ignorecase \
logAllRefUpdates loosecompression notesRef \
packedGitLimit packedGitWindowSize pager \
preferSymlinkRefs preloadindex quotepath \
repositoryFormatVersion safecrlf \
sharedRepository sparseCheckout symlinks \
trustctime warnAmbiguousRefs whitespace \
worktree
;; #<<#
(diff.*.*)
word=${word#diff.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
binary cachetextconv command textconv \
wordregex xfuncname
;; #<<#
(diff.*)
PREFIX=${PREFIX}diff. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autorefreshindex dirstat external \
ignoreSubmodules mnemonicprefix noprefix \
renameLimit renames suppressBlankEmpty tool \
wordRegex
;; #<<#
# (difftool.*.*) -> (browser.*.*)
(difftool.*)
PREFIX=${PREFIX}difftool. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
prompt
;; #<<#
(fetch.*)
PREFIX=${PREFIX}fetch. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
recurseSubmodules unpackLimit
;; #<<#
(format.*)
PREFIX=${PREFIX}format. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
attach cc numbered headers pretty signature \
signoff subjectprefix suffix thread to
;; #<<#
(filter.*.*)
word=${word#filter.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
clean smudge
;; #<<#
(gc.*.*)
word=${word#gc.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
reflogexpire reflogexpireunreachable
;; #<<#
(gc.*)
PREFIX=${PREFIX}gc. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
aggressiveWindow auto autopacklimit packrefs \
pruneexpire reflogexpire \
reflogexpireunreachable \
rerereresolved rerereunresolved
;; #<<#
(gitcvs.*)
PREFIX=${PREFIX}gitcvs. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
allbinary commitmsgannotation \
dbTableNamePrefix dbdriver dbname dbpass \
dbuser enabled logfile usecrlfattr
;; #<<#
(grep.*)
PREFIX=${PREFIX}grep. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
extendedRegexp lineNumber
;; #<<#
(gui.*)
PREFIX=${PREFIX}gui. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
blamehistoryctx commitmsgwidth \
copyblamethreshold diffcontext encoding \
fastcopyblame matchtrackingbranch \
newbranchtemplate pruneduringfetch \
spellingdictionary trustmtime
;; #<<#
(guitool.*.*)
word=${word#guitool.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
argropmpt cmd confirm needsfile noconsole \
norescan prompt revprompt revunmerged title
;; #<<#
(help.*)
PREFIX=${PREFIX}help. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autocorrect browser format
;; #<<#
(http.*)
PREFIX=${PREFIX}http. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
cookiefile lowSpeedLimit lowSpeedTime \
maxRequests minSessions noEPSV postBuffer \
proxy sslCAInfo sslCAPath sslCert \
sslCertPasswordProtected sslKey sslVerify \
useragent
;; #<<#
(i18n.*)
PREFIX=${PREFIX}i18n. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
commitEncoding logOutputEncoding
;; #<<#
(imap.*)
PREFIX=${PREFIX}imap. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
authMethod folder host pass port \
preformattedHTML sslverify tunnel user
;; #<<#
(init.*)
PREFIX=${PREFIX}init. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
templatedir
;; #<<#
(instaweb.*)
PREFIX=${PREFIX}instaweb. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
browser httpd local modulepath port
;; #<<#
(interactive.*)
PREFIX=${PREFIX}interactive. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
singlekey
;; #<<#
(log.*)
PREFIX=${PREFIX}log. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
abbrevCommit date decorate showroot
;; #<<#
(mailmap.*)
PREFIX=${PREFIX}mailmap. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
file
;; #<<#
# (man.*.*) -> (browser.*.*)
(man.*)
PREFIX=${PREFIX}man. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
viewer
;; #<<#
(merge.*.*)
word=${word#merge.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
driver name recursive
;; #<<#
(merge.*)
PREFIX=${PREFIX}merge. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
conflictstyle defaultToUpstream ff log \
renameLimit renormalize stat tool verbosity
;; #<<#
(mergetool.*.*)
word=${word#mergetool.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
cmd path trustExitCode
;; #<<#
(mergetool.*)
PREFIX=${PREFIX}mergetool. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
keepBackup keepTemporaries prompt
;; #<<#
(notes.*)
PREFIX=${PREFIX}notes. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
displayRef rewriteMode rewriteRef
complete -P "$PREFIX" -S . -T -- rewrite
;; #<<#
(pack.*)
PREFIX=${PREFIX}pack. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
compression deltaCacheLimit deltaCacheSize \
depth indexVersion packSizeLimit threads \
window windowMemory
;; #<<#
(pull.*)
PREFIX=${PREFIX}pull. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
octopus twohead
;; #<<#
(push.*)
PREFIX=${PREFIX}push. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
default
;; #<<#
(rebase.*)
PREFIX=${PREFIX}rebase. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autosquash stat
;; #<<#
(receive.*)
PREFIX=${PREFIX}receive. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autogc denyCurrentBranch denyDeleteCurrent \
denyDeletes denyNonFastForwards fsckObjects \
unpackLimit updateserverinfo
;; #<<#
(remote.*.*)
word=${word#remote.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
fetch mirror proxy push pushurl receivepack \
skipDefaultUpdate skipFetchAll tagopt \
uploadpack url vcs
;; #<<#
(repack.*)
PREFIX=${PREFIX}repack. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
usedeltabaseoffset
;; #<<#
(rerere.*)
PREFIX=${PREFIX}rerere. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
autoupdate enabled
;; #<<#
(sendemail.*.*)
word=${word#sendemail.*.}
PREFIX=${TARGETWORD%"$word"}
command -f completion//git::completesendemailoptionname
;;
(sendemail.*)
PREFIX=${PREFIX}sendemail. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
identity smtpencryption
#<<#
command -f completion//git::completesendemailoptionname
;;
(status.*)
PREFIX=${PREFIX}status. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
relativePaths showUntrackedFiles \
submodulesummary
;; #<<#
(submodule.*.*)
word=${word#submodule.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
fetchRecurseSubmodules ignore path update url
;; #<<#
(svn-remote.*.*)
word=${word#svn-remote.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
automkdirs branches commiturl fetch \
ignore-paths noMetadata pushurl rewriteRoot \
rewriteUUID tags url useSvmProps useSvnsyncprops
;; #<<#
(svn.*)
PREFIX=${PREFIX}svn. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
automkdirs authorsfile brokenSymlinkWorkaround \
commiturl edit findcopiesharder followparent l \
noMetadata pathnameencoding pushmergeinfo \
repack repackflags rmdir useSvmProps \
useSvnsyncprops
;; #<<#
(tar.*)
PREFIX=${PREFIX}tar. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
umask
;; #<<#
(transfer.*)
PREFIX=${PREFIX}transfer. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
unpackLimit
;; #<<#
(url.*.*)
word=${word#url.*.}
PREFIX=${TARGETWORD%"$word"} #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
insteadOf pushInsteadOf
;; #<<#
(user.*)
PREFIX=${PREFIX}user. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
email name signingkey
;; #<<#
(web.*)
PREFIX=${PREFIX}web. #>>#
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
browser
;; #<<#
(*) #>>#
complete -P "$PREFIX" -S . -T -- \
add advice alias am apply branch browser clean \
color commit core diff difftool fetch format \
filter gc gitcvs grep gui guitool help http \
i18n imap init instaweb interactive log \
mailmap man merge mergetool notes pack pager \
pretty pull push rebase receive remote remotes \
repack rerere sendemail showbranch status \
submodule svn svn-remote tar transfer url user \
web
;; #<<#
esac
}
function completion//git::completesendemailoptionname {
complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \
aliasesfile aliasfiletype bcc cc cccmd chainreplyto confirm \
envelopesender from multiedit signedoffbycc smtpdomain \
smtppass smtpserver smtpserveroption smtpserverport smtpuser \
suppresscc suppressfrom thread to validate
}
# vim: set ft=sh ts=8 sts=8 sw=8 noet:
|