forked from ggreer/the_silver_searcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathag.bashcomp.sh
132 lines (123 loc) · 2.35 KB
/
ag.bashcomp.sh
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
_ag() {
local lngopt shtopt split=false
local cur prev
COMPREPLY=()
cur=$(_get_cword "=")
prev="${COMP_WORDS[COMP_CWORD-1]}"
_expand || return 0
lngopt='
--ackmate
--ackmate-dir-filter
--affinity
--after
--all-text
--all-types
--before
--break
--case-sensitive
--color
--color-line-number
--color-match
--color-path
--color-win-ansi
--column
--context
--count
--debug
--depth
--file-search-regex
--filename
--files-with-matches
--files-without-matches
--fixed-strings
--follow
--group
--heading
--help
--hidden
--ignore
--ignore-case
--ignore-dir
--invert-match
--line-numbers
--list-file-types
--literal
--match
--max-count
--no-numbers
--no-recurse
--noaffinity
--nobreak
--nocolor
--nofilename
--nofollow
--nogroup
--noheading
--nonumbers
--nopager
--norecurse
--null
--numbers
--one-device
--only-matching
--pager
--parallel
--passthrough
--passthru
--path-to-agignore
--print-long-lines
--print0
--recurse
--search-binary
--search-files
--search-zip
--silent
--skip-vcs-ignores
--smart-case
--stats
--unrestricted
--version
--vimgrep
--word-regexp
--workers
'
shtopt='
-a -A -B -C -D
-f -F -g -G -h
-i -l -L -m -n
-p -Q -r -R -s
-S -t -u -U -v
-V -w -z
'
types=$(ag --list-file-types |grep -- '--')
# these options require an argument
if [[ "${prev}" == -[ABCGgm] ]] ; then
return 0
fi
_split_longopt && split=true
case "${prev}" in
--ignore-dir) # directory completion
_filedir -d
return 0;;
--path-to-agignore) # file completion
_filedir
return 0;;
--pager) # command completion
COMPREPLY=( $(compgen -c -- "${cur}") )
return 0;;
--ackmate-dir-filter|--after|--before|--color-*|--context|--depth\
|--file-search-regex|--ignore|--max-count|--workers)
return 0;;
esac
$split && return 0
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W \
"${lngopt} ${shtopt} ${types}" -- "${cur}") )
return 0;;
*)
_filedir
return 0;;
esac
} &&
complete -F _ag ${nospace} ag