| 1 |
# Bash completion for patchutils commands |
| 2 |
# Generated for patchutils package |
| 3 |
|
| 4 |
# Common options used across multiple commands |
| 5 |
_patchutils_common_opts() { |
| 6 |
echo "--help --version" |
| 7 |
} |
| 8 |
|
| 9 |
_patchutils_shared_filter_opts() { |
| 10 |
echo "--exclude -x --exclude-from-file -X --include -i --include-from-file -I --hunks -# --lines --files -F --decompress -z --strip-match -p --strip --addprefix --addoldprefix --addnewprefix --git-prefixes" |
| 11 |
} |
| 12 |
|
| 13 |
_patchutils_filterdiff_only_opts() { |
| 14 |
echo "--annotate --as-numbered-lines --format --remove-timestamps --clean --in-place" |
| 15 |
} |
| 16 |
|
| 17 |
_patchutils_list_opts() { |
| 18 |
echo "--line-number -n --number-files -N --with-filename -H --no-filename -h --status -s --empty-files-as-absent -E" |
| 19 |
} |
| 20 |
|
| 21 |
_patchutils_grep_opts() { |
| 22 |
echo "--output-matching --only-match --extended-regexp -E --file -f" |
| 23 |
} |
| 24 |
|
| 25 |
_patchutils_interdiff_opts() { |
| 26 |
echo "--unified -U --ignore-case -i --ignore-all-space -w --ignore-space-change -b --ignore-blank-lines -B --color --quiet -q --drop-context -d --decompress -z --strip-match -p --interpolate --combine --flip --no-revert-omitted --in-place" |
| 27 |
} |
| 28 |
|
| 29 |
# File completion helper |
| 30 |
_patchutils_files() { |
| 31 |
local cur="${COMP_WORDS[COMP_CWORD]}" |
| 32 |
COMPREPLY=($(compgen -f -- "$cur")) |
| 33 |
} |
| 34 |
|
| 35 |
# Completion for filterdiff |
| 36 |
_filterdiff() { |
| 37 |
local cur prev opts |
| 38 |
COMP_WORDBREAKS=${COMP_WORDBREAKS//=} |
| 39 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 40 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 41 |
|
| 42 |
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts) $(_patchutils_list_opts) --verbose -v --filter --grep --list" |
| 43 |
|
| 44 |
case "${prev}" in |
| 45 |
--exclude|-x|--include|-i) |
| 46 |
# Pattern completion - no specific completion |
| 47 |
return 0 |
| 48 |
;; |
| 49 |
--exclude-from-file|-X|--include-from-file|-I|--file|-f) |
| 50 |
_patchutils_files |
| 51 |
return 0 |
| 52 |
;; |
| 53 |
--hunks|-#|--lines|--files|-F) |
| 54 |
# Range completion - no specific completion |
| 55 |
return 0 |
| 56 |
;; |
| 57 |
--as-numbered-lines) |
| 58 |
COMPREPLY=($(compgen -W "before after original-before original-after" -- "$cur")) |
| 59 |
return 0 |
| 60 |
;; |
| 61 |
--format) |
| 62 |
COMPREPLY=($(compgen -W "context unified" -- "$cur")) |
| 63 |
return 0 |
| 64 |
;; |
| 65 |
--output-matching) |
| 66 |
COMPREPLY=($(compgen -W "hunk file" -- "$cur")) |
| 67 |
return 0 |
| 68 |
;; |
| 69 |
--only-match) |
| 70 |
COMPREPLY=($(compgen -W "rem removals add additions mod modifications all" -- "$cur")) |
| 71 |
return 0 |
| 72 |
;; |
| 73 |
--strip-match|-p|--strip) |
| 74 |
# Number completion - no specific completion |
| 75 |
return 0 |
| 76 |
;; |
| 77 |
--addprefix|--addoldprefix|--addnewprefix) |
| 78 |
# Prefix completion - no specific completion |
| 79 |
return 0 |
| 80 |
;; |
| 81 |
--git-prefixes) |
| 82 |
COMPREPLY=($(compgen -W "strip keep" -- "$cur")) |
| 83 |
return 0 |
| 84 |
;; |
| 85 |
esac |
| 86 |
|
| 87 |
if [[ ${cur} == -* ]]; then |
| 88 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 89 |
return 0 |
| 90 |
fi |
| 91 |
|
| 92 |
_patchutils_files |
| 93 |
} |
| 94 |
|
| 95 |
# Completion for lsdiff (same as filterdiff with --list mode) |
| 96 |
_lsdiff() { |
| 97 |
local cur prev opts |
| 98 |
COMP_WORDBREAKS=${COMP_WORDBREAKS//=} |
| 99 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 100 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 101 |
|
| 102 |
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_list_opts) --verbose -v --filter --grep" |
| 103 |
|
| 104 |
case "${prev}" in |
| 105 |
--exclude|-x|--include|-i) |
| 106 |
return 0 |
| 107 |
;; |
| 108 |
--exclude-from-file|-X|--include-from-file|-I) |
| 109 |
_patchutils_files |
| 110 |
return 0 |
| 111 |
;; |
| 112 |
--hunks|-#|--lines|--files|-F) |
| 113 |
return 0 |
| 114 |
;; |
| 115 |
--strip-match|-p|--strip) |
| 116 |
return 0 |
| 117 |
;; |
| 118 |
--addprefix|--addoldprefix|--addnewprefix) |
| 119 |
return 0 |
| 120 |
;; |
| 121 |
--git-prefixes) |
| 122 |
COMPREPLY=($(compgen -W "strip keep" -- "$cur")) |
| 123 |
return 0 |
| 124 |
;; |
| 125 |
esac |
| 126 |
|
| 127 |
if [[ ${cur} == -* ]]; then |
| 128 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 129 |
return 0 |
| 130 |
fi |
| 131 |
|
| 132 |
_patchutils_files |
| 133 |
} |
| 134 |
|
| 135 |
# Completion for grepdiff |
| 136 |
_grepdiff() { |
| 137 |
local cur prev opts |
| 138 |
COMP_WORDBREAKS=${COMP_WORDBREAKS//=} |
| 139 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 140 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 141 |
|
| 142 |
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_list_opts) $(_patchutils_grep_opts) --verbose -v --filter --list" |
| 143 |
|
| 144 |
case "${prev}" in |
| 145 |
--exclude|-x|--include|-i) |
| 146 |
return 0 |
| 147 |
;; |
| 148 |
--exclude-from-file|-X|--include-from-file|-I|--file|-f) |
| 149 |
_patchutils_files |
| 150 |
return 0 |
| 151 |
;; |
| 152 |
--hunks|-#|--lines|--files|-F) |
| 153 |
return 0 |
| 154 |
;; |
| 155 |
--as-numbered-lines) |
| 156 |
COMPREPLY=($(compgen -W "before after original-before original-after" -- "$cur")) |
| 157 |
return 0 |
| 158 |
;; |
| 159 |
--format) |
| 160 |
COMPREPLY=($(compgen -W "context unified" -- "$cur")) |
| 161 |
return 0 |
| 162 |
;; |
| 163 |
--output-matching) |
| 164 |
COMPREPLY=($(compgen -W "hunk file" -- "$cur")) |
| 165 |
return 0 |
| 166 |
;; |
| 167 |
--only-match) |
| 168 |
COMPREPLY=($(compgen -W "rem removals add additions mod modifications all" -- "$cur")) |
| 169 |
return 0 |
| 170 |
;; |
| 171 |
--strip-match|-p|--strip) |
| 172 |
return 0 |
| 173 |
;; |
| 174 |
--addprefix|--addoldprefix|--addnewprefix) |
| 175 |
return 0 |
| 176 |
;; |
| 177 |
--git-prefixes) |
| 178 |
COMPREPLY=($(compgen -W "strip keep" -- "$cur")) |
| 179 |
return 0 |
| 180 |
;; |
| 181 |
esac |
| 182 |
|
| 183 |
if [[ ${cur} == -* ]]; then |
| 184 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 185 |
return 0 |
| 186 |
fi |
| 187 |
|
| 188 |
_patchutils_files |
| 189 |
} |
| 190 |
|
| 191 |
# Completion for interdiff, combinediff, flipdiff |
| 192 |
_interdiff() { |
| 193 |
local cur prev opts |
| 194 |
COMP_WORDBREAKS=${COMP_WORDBREAKS//=} |
| 195 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 196 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 197 |
|
| 198 |
opts="$(_patchutils_common_opts) $(_patchutils_interdiff_opts)" |
| 199 |
|
| 200 |
case "${prev}" in |
| 201 |
--unified|-U) |
| 202 |
# Number completion |
| 203 |
return 0 |
| 204 |
;; |
| 205 |
--drop-context|-d) |
| 206 |
# Pattern completion |
| 207 |
return 0 |
| 208 |
;; |
| 209 |
--strip-match|-p) |
| 210 |
# Number completion |
| 211 |
return 0 |
| 212 |
;; |
| 213 |
--color) |
| 214 |
COMPREPLY=($(compgen -W "never always auto" -- "$cur")) |
| 215 |
return 0 |
| 216 |
;; |
| 217 |
esac |
| 218 |
|
| 219 |
if [[ ${cur} == -* ]]; then |
| 220 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 221 |
return 0 |
| 222 |
fi |
| 223 |
|
| 224 |
_patchutils_files |
| 225 |
} |
| 226 |
|
| 227 |
# Completion for rediff |
| 228 |
_rediff() { |
| 229 |
local cur prev opts |
| 230 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 231 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 232 |
|
| 233 |
opts="--help --version --in-place" |
| 234 |
|
| 235 |
if [[ ${cur} == -* ]]; then |
| 236 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 237 |
return 0 |
| 238 |
fi |
| 239 |
|
| 240 |
_patchutils_files |
| 241 |
} |
| 242 |
|
| 243 |
# Completion for splitdiff |
| 244 |
_splitdiff() { |
| 245 |
local cur prev opts |
| 246 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 247 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 248 |
|
| 249 |
opts="--help --version -a -p -d -D -E" |
| 250 |
|
| 251 |
case "${prev}" in |
| 252 |
-p) |
| 253 |
# Number completion |
| 254 |
return 0 |
| 255 |
;; |
| 256 |
-D) |
| 257 |
# Directory completion |
| 258 |
COMPREPLY=($(compgen -d -- "$cur")) |
| 259 |
return 0 |
| 260 |
;; |
| 261 |
esac |
| 262 |
|
| 263 |
if [[ ${cur} == -* ]]; then |
| 264 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 265 |
return 0 |
| 266 |
fi |
| 267 |
|
| 268 |
_patchutils_files |
| 269 |
} |
| 270 |
|
| 271 |
# Completion for recountdiff |
| 272 |
_recountdiff() { |
| 273 |
local cur prev opts |
| 274 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 275 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 276 |
|
| 277 |
opts="--help --version" |
| 278 |
|
| 279 |
if [[ ${cur} == -* ]]; then |
| 280 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 281 |
return 0 |
| 282 |
fi |
| 283 |
|
| 284 |
_patchutils_files |
| 285 |
} |
| 286 |
|
| 287 |
# Completion for unwrapdiff |
| 288 |
_unwrapdiff() { |
| 289 |
local cur prev opts |
| 290 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 291 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 292 |
|
| 293 |
opts="--help --version" |
| 294 |
|
| 295 |
if [[ ${cur} == -* ]]; then |
| 296 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 297 |
return 0 |
| 298 |
fi |
| 299 |
|
| 300 |
_patchutils_files |
| 301 |
} |
| 302 |
|
| 303 |
# Completion for dehtmldiff |
| 304 |
_dehtmldiff() { |
| 305 |
local cur prev opts |
| 306 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 307 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 308 |
|
| 309 |
opts="--help --version" |
| 310 |
|
| 311 |
if [[ ${cur} == -* ]]; then |
| 312 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 313 |
return 0 |
| 314 |
fi |
| 315 |
|
| 316 |
_patchutils_files |
| 317 |
} |
| 318 |
|
| 319 |
# Completion for editdiff |
| 320 |
_editdiff() { |
| 321 |
local cur prev opts |
| 322 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 323 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 324 |
|
| 325 |
opts="--help --version" |
| 326 |
|
| 327 |
if [[ ${cur} == -* ]]; then |
| 328 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 329 |
return 0 |
| 330 |
fi |
| 331 |
|
| 332 |
_patchutils_files |
| 333 |
} |
| 334 |
|
| 335 |
# Completion for espdiff |
| 336 |
_espdiff() { |
| 337 |
local cur prev opts |
| 338 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 339 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 340 |
|
| 341 |
opts="--help --version" |
| 342 |
|
| 343 |
if [[ ${cur} == -* ]]; then |
| 344 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 345 |
return 0 |
| 346 |
fi |
| 347 |
|
| 348 |
_patchutils_files |
| 349 |
} |
| 350 |
|
| 351 |
# Completion for fixcvsdiff |
| 352 |
_fixcvsdiff() { |
| 353 |
local cur prev opts |
| 354 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 355 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 356 |
|
| 357 |
opts="--help --version -p -b" |
| 358 |
|
| 359 |
if [[ ${cur} == -* ]]; then |
| 360 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 361 |
return 0 |
| 362 |
fi |
| 363 |
|
| 364 |
_patchutils_files |
| 365 |
} |
| 366 |
|
| 367 |
# Completion for patchview |
| 368 |
_patchview() { |
| 369 |
local cur prev opts |
| 370 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 371 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 372 |
|
| 373 |
# patchview is a wrapper around filterdiff, so use similar completion |
| 374 |
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts) --verbose -v --filter --grep" |
| 375 |
|
| 376 |
case "${prev}" in |
| 377 |
--exclude|-x|--include|-i) |
| 378 |
return 0 |
| 379 |
;; |
| 380 |
--exclude-from-file|-X|--include-from-file|-I) |
| 381 |
_patchutils_files |
| 382 |
return 0 |
| 383 |
;; |
| 384 |
--hunks|-#|--lines|--files|-F) |
| 385 |
return 0 |
| 386 |
;; |
| 387 |
--strip-match|-p|--strip) |
| 388 |
return 0 |
| 389 |
;; |
| 390 |
--addprefix|--addoldprefix|--addnewprefix) |
| 391 |
return 0 |
| 392 |
;; |
| 393 |
--git-prefixes) |
| 394 |
COMPREPLY=($(compgen -W "strip keep" -- "$cur")) |
| 395 |
return 0 |
| 396 |
;; |
| 397 |
esac |
| 398 |
|
| 399 |
if [[ ${cur} == -* ]]; then |
| 400 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 401 |
return 0 |
| 402 |
fi |
| 403 |
|
| 404 |
_patchutils_files |
| 405 |
} |
| 406 |
|
| 407 |
# Simple completion for git/svn diff wrappers |
| 408 |
_gitdiff() { |
| 409 |
local cur prev opts |
| 410 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 411 |
|
| 412 |
# These are wrappers that pass arguments to filterdiff |
| 413 |
opts="$(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts)" |
| 414 |
|
| 415 |
if [[ ${cur} == -* ]]; then |
| 416 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
| 417 |
return 0 |
| 418 |
fi |
| 419 |
|
| 420 |
return 0 |
| 421 |
} |
| 422 |
|
| 423 |
_svndiff() { |
| 424 |
_gitdiff |
| 425 |
} |
| 426 |
|
| 427 |
_gitdiffview() { |
| 428 |
_gitdiff |
| 429 |
} |
| 430 |
|
| 431 |
_svndiffview() { |
| 432 |
_gitdiff |
| 433 |
} |
| 434 |
|
| 435 |
# Register completions for all patchutils commands |
| 436 |
complete -F _filterdiff filterdiff |
| 437 |
complete -F _lsdiff lsdiff |
| 438 |
complete -F _grepdiff grepdiff |
| 439 |
complete -F _interdiff interdiff |
| 440 |
complete -F _interdiff combinediff |
| 441 |
complete -F _interdiff flipdiff |
| 442 |
complete -F _rediff rediff |
| 443 |
complete -F _splitdiff splitdiff |
| 444 |
complete -F _recountdiff recountdiff |
| 445 |
complete -F _unwrapdiff unwrapdiff |
| 446 |
complete -F _dehtmldiff dehtmldiff |
| 447 |
complete -F _editdiff editdiff |
| 448 |
complete -F _espdiff espdiff |
| 449 |
complete -F _fixcvsdiff fixcvsdiff |
| 450 |
complete -F _patchview patchview |
| 451 |
complete -F _gitdiff gitdiff |
| 452 |
complete -F _svndiff svndiff |
| 453 |
complete -F _gitdiffview gitdiffview |
| 454 |
complete -F _svndiffview svndiffview |
| 455 |
complete -F _gitdiff gitshow |
| 456 |
complete -F _gitdiff gitshowview |