trace-cmd list: Show events in bash completion
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.
Link: https://lore.kernel.org/20250408113704.42fb24c8@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
diff --git a/tracecmd/trace-cmd.bash b/tracecmd/trace-cmd.bash
index d7816bc..ee7c79a 100644
--- a/tracecmd/trace-cmd.bash
+++ b/tracecmd/trace-cmd.bash
@@ -84,6 +84,12 @@
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