aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-11-17 11:13:26 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-27 12:58:35 -0500
commitf38ab8af794c184c15f5e001d0eaa16f4a120978 (patch)
tree463e41661037fe52ca5371a82dbbd19e4039103b
parent37e72c31061521d6f0e4b7fe47cd5748280ed691 (diff)
perf completion: Introduce zsh support
__perfcomp(), __perfcomp_colon(), and _perf() have to be overridden. Inspired by the way the git.git completion system is structured. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1384704807-15779-5-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/bash_completion63
1 files changed, 62 insertions, 1 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 573599b42be2..49494882d9bb 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,4 +1,4 @@
1# perf completion 1# perf bash and zsh completion
2 2
3# Taken from git.git's completion script. 3# Taken from git.git's completion script.
4__my_reassemble_comp_words_by_ref() 4__my_reassemble_comp_words_by_ref()
@@ -129,6 +129,67 @@ __perf_main ()
129 fi 129 fi
130} 130}
131 131
132if [[ -n ${ZSH_VERSION-} ]]; then
133 autoload -U +X compinit && compinit
134
135 __perfcomp ()
136 {
137 emulate -L zsh
138
139 local c IFS=$' \t\n'
140 local -a array
141
142 for c in ${=1}; do
143 case $c in
144 --*=*|*.) ;;
145 *) c="$c " ;;
146 esac
147 array[${#array[@]}+1]="$c"
148 done
149
150 compset -P '*[=:]'
151 compadd -Q -S '' -a -- array && _ret=0
152 }
153
154 __perfcomp_colon ()
155 {
156 emulate -L zsh
157
158 local cur_="${2-$cur}"
159 local c IFS=$' \t\n'
160 local -a array
161
162 if [[ "$cur_" == *:* ]]; then
163 local colon_word=${cur_%"${cur_##*:}"}
164 fi
165
166 for c in ${=1}; do
167 case $c in
168 --*=*|*.) ;;
169 *) c="$c " ;;
170 esac
171 array[$#array+1]=${c#"$colon_word"}
172 done
173
174 compset -P '*[=:]'
175 compadd -Q -S '' -a -- array && _ret=0
176 }
177
178 _perf ()
179 {
180 local _ret=1 cur cword prev
181 cur=${words[CURRENT]}
182 prev=${words[CURRENT-1]}
183 let cword=CURRENT-1
184 emulate ksh -c __perf_main
185 let _ret && _default && _ret=0
186 return _ret
187 }
188
189 compdef _perf perf
190 return
191fi
192
132type perf &>/dev/null && 193type perf &>/dev/null &&
133_perf() 194_perf()
134{ 195{