From: Ramkumar Ramachandra <artagnon@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Namhyung Kim <namhyung@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>
Subject: [PATCH 4/5] perf completion: introduce zsh support
Date: Sun, 17 Nov 2013 21:43:26 +0530 [thread overview]
Message-ID: <1384704807-15779-5-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1384704807-15779-1-git-send-email-artagnon@gmail.com>
__perfcomp(), __perfcomp_colon(), and _perf() have to be
overridden. Inspired by the way the git.git completion system is
structured.
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
tools/perf/bash_completion | 63 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 573599b..4949488 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,4 +1,4 @@
-# perf completion
+# perf bash and zsh completion
# Taken from git.git's completion script.
__my_reassemble_comp_words_by_ref()
@@ -129,6 +129,67 @@ __perf_main ()
fi
}
+if [[ -n ${ZSH_VERSION-} ]]; then
+ autoload -U +X compinit && compinit
+
+ __perfcomp ()
+ {
+ emulate -L zsh
+
+ local c IFS=$' \t\n'
+ local -a array
+
+ for c in ${=1}; do
+ case $c in
+ --*=*|*.) ;;
+ *) c="$c " ;;
+ esac
+ array[${#array[@]}+1]="$c"
+ done
+
+ compset -P '*[=:]'
+ compadd -Q -S '' -a -- array && _ret=0
+ }
+
+ __perfcomp_colon ()
+ {
+ emulate -L zsh
+
+ local cur_="${2-$cur}"
+ local c IFS=$' \t\n'
+ local -a array
+
+ if [[ "$cur_" == *:* ]]; then
+ local colon_word=${cur_%"${cur_##*:}"}
+ fi
+
+ for c in ${=1}; do
+ case $c in
+ --*=*|*.) ;;
+ *) c="$c " ;;
+ esac
+ array[$#array+1]=${c#"$colon_word"}
+ done
+
+ compset -P '*[=:]'
+ compadd -Q -S '' -a -- array && _ret=0
+ }
+
+ _perf ()
+ {
+ local _ret=1 cur cword prev
+ cur=${words[CURRENT]}
+ prev=${words[CURRENT-1]}
+ let cword=CURRENT-1
+ emulate ksh -c __perf_main
+ let _ret && _default && _ret=0
+ return _ret
+ }
+
+ compdef _perf perf
+ return
+fi
+
type perf &>/dev/null &&
_perf()
{
--
1.8.5.rc0.6.gfd75b41
next prev parent reply other threads:[~2013-11-17 16:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-17 16:13 [PATCH 0/5] zsh support for perf completion Ramkumar Ramachandra
2013-11-17 16:13 ` [PATCH 1/5] perf completion: introduce a layer of indirection Ramkumar Ramachandra
2013-11-30 12:49 ` [tip:perf/core] perf completion: Introduce " tip-bot for Ramkumar Ramachandra
2013-11-17 16:13 ` [PATCH 2/5] perf completion: factor out compgen stuff Ramkumar Ramachandra
2013-11-30 12:49 ` [tip:perf/core] perf completion: Factor " tip-bot for Ramkumar Ramachandra
2013-11-17 16:13 ` [PATCH 3/5] perf completion: factor out call to __ltrim_colon_completions Ramkumar Ramachandra
2013-11-30 12:49 ` [tip:perf/core] perf completion: Factor " tip-bot for Ramkumar Ramachandra
2013-11-17 16:13 ` Ramkumar Ramachandra [this message]
2013-11-30 12:50 ` [tip:perf/core] perf completion: Introduce zsh support tip-bot for Ramkumar Ramachandra
2013-11-17 16:13 ` [PATCH 5/5] perf completion: rename file to reflect " Ramkumar Ramachandra
2013-11-30 12:50 ` [tip:perf/core] perf completion: Rename " tip-bot for Ramkumar Ramachandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384704807-15779-5-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=acme@ghostprotocols.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox