diff mbox series

[2/3] trace-cmd record: Update -e event bash tab completion

Message ID 20210417004637.3899514-3-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit f6751f64f58f16325b5cb07012a152bccceaba57
Headers show
Series trace-cmd: Updated bash tab completion | expand

Commit Message

Steven Rostedt April 17, 2021, 12:46 a.m. UTC
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 mbox series

Patch

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