linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: <linux-trace-devel@vger.kernel.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Subject: [PATCH 2/3] trace-cmd record: Update -e event bash tab completion
Date: Fri, 16 Apr 2021 20:46:36 -0400	[thread overview]
Message-ID: <20210417004637.3899514-3-rostedt@goodmis.org> (raw)
In-Reply-To: <20210417004637.3899514-1-rostedt@goodmis.org>

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Update the tab completion to find events instead of needing to know the
systems.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-cmd.bash | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tracecmd/trace-cmd.bash b/tracecmd/trace-cmd.bash
index e89c1a55..9b0703b7 100644
--- a/tracecmd/trace-cmd.bash
+++ b/tracecmd/trace-cmd.bash
@@ -142,10 +142,16 @@ __trace_cmd_record_complete()
 
     case "$prev" in
         -e)
-            local events=$(trace-cmd list -e)
+	    local list=$(trace-cmd list -e "$cur")
             local prefix=${cur%%:*}
+	    if [ -z "$cur" -o  "$cur" != "$prefix" ]; then
+		COMPREPLY=( $(compgen -W "all ${list}" -- "${cur}") )
+	    else
+		local events=$(for e in $list; do echo ${e/*:/}; done | sort -u)
+	        local systems=$(for s in $list; do echo ${s/:*/:}; done | sort -u)
 
-            COMPREPLY=( $(compgen -W "${events}" -- "${cur}") )
+		COMPREPLY=( $(compgen -W "all ${events} ${systems}" -- "${cur}") )
+	    fi
 
             # This is still to handle the "*:*" special case
             if [[ -n "$prefix" ]]; then
-- 
2.29.2


  parent reply	other threads:[~2021-04-17  0:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17  0:46 [PATCH 0/3] trace-cmd: Updated bash tab completion Steven Rostedt
2021-04-17  0:46 ` [PATCH 1/3] trace-cmd record: Add bash tab completion for -A Steven Rostedt
2021-04-17  0:46 ` Steven Rostedt [this message]
2021-04-17  0:46 ` [PATCH 3/3] trace-cmd completion: Add instance completion for -B Steven Rostedt

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=20210417004637.3899514-3-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.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;
as well as URLs for NNTP newsgroup(s).