blob: bba184ceb4a5100963dad5f68d4b56103272e100 (
plain)
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
|
# patch(1) completion -*- shell-script -*-
_comp_cmd_patch()
{
local cur prev words cword was_split comp_args
_comp_initialize -s -- "$@" || return
local noargopts='!(-*|*[pDBYzgFiorVd]*)'
# shellcheck disable=SC2254
case $prev in
--strip | --ifdef | --prefix | --basename-prefix | --suffix | --get | \
-${noargopts}[pDBYzg])
return
;;
--fuzz | -${noargopts}F)
_comp_compgen -- -W '{0..3}'
return
;;
--input | -${noargopts}i)
_comp_compgen_filedir '@(?(d)patch|dif?(f))'
return
;;
--output | --reject-file | -${noargopts}[or])
[[ ! $cur || $cur == - ]] && COMPREPLY=(-)
_comp_compgen -a filedir
return
;;
--quoting-style)
_comp_compgen -- -W 'literal shell shell-always c escape'
return
;;
--version-control | -${noargopts}V)
_comp_compgen -- -W 'simple numbered existing'
return
;;
--directory | -${noargopts}d)
_comp_compgen_filedir -d
return
;;
--reject-format)
_comp_compgen -- -W 'context unified'
return
;;
--read-only)
_comp_compgen -- -W 'ignore warn fail'
return
;;
esac
[[ $was_split ]] && return
if [[ $cur == -* ]]; then
_comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
local REPLY
_comp_count_args
case $REPLY in
1)
_comp_compgen_filedir
;;
2)
_comp_compgen_filedir '@(?(d)patch|dif?(f))'
;;
esac
} &&
complete -F _comp_cmd_patch patch
# ex: filetype=sh
|