Skip to contentSkip to conversation

trace-cmd list: Show events in bash completion

PATCH New Steven Rostedt 1 participant 1 message Apr 8, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd list: Show events in bash completion

From: "Steven Rostedt (Google)" <[email protected]>

Even though trace-cmd list -e shows the events, there's several times where it is useful to see a format of an event that is known, and having tab completion for those events would be useful.

---
 tracecmd/trace-cmd.bash | 6 ++++++
 1 file changed, 6 insertions(+)
tracecmd/trace-cmd.bash +6 -0
index d7816bcf..ee7c79a2 100644
@@ -84,6 +84,12 @@ __trace_cmd_list_complete()
 				 sed -e 's/.*\(-.\).*/\1/')
 	    COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
 	    ;;
+	-e)
+	    local list=$(trace-cmd list -e "$cur")
+	    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 "all ${events} ${systems}" -- "${cur}") )
+	    ;;
 	*)
 	    size=${#words[@]}
 	    if [ $size -gt 3 ]; then
Signature · 1 line
2.47.2