diff options
Diffstat (limited to 'tools/perf/bash_completion')
-rw-r--r-- | tools/perf/bash_completion | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion index 3efdc84f112c..824312681601 100644 --- a/tools/perf/bash_completion +++ b/tools/perf/bash_completion | |||
@@ -89,6 +89,11 @@ __ltrim_colon_completions() | |||
89 | fi | 89 | fi |
90 | } | 90 | } |
91 | 91 | ||
92 | __perfcomp () | ||
93 | { | ||
94 | COMPREPLY=( $( compgen -W "$1" -- "$2" ) ) | ||
95 | } | ||
96 | |||
92 | __perf_main () | 97 | __perf_main () |
93 | { | 98 | { |
94 | local cmd | 99 | local cmd |
@@ -99,23 +104,23 @@ __perf_main () | |||
99 | # List perf subcommands or long options | 104 | # List perf subcommands or long options |
100 | if [ $cword -eq 1 ]; then | 105 | if [ $cword -eq 1 ]; then |
101 | if [[ $cur == --* ]]; then | 106 | if [[ $cur == --* ]]; then |
102 | COMPREPLY=( $( compgen -W '--help --version \ | 107 | __perfcomp '--help --version \ |
103 | --exec-path --html-path --paginate --no-pager \ | 108 | --exec-path --html-path --paginate --no-pager \ |
104 | --perf-dir --work-tree --debugfs-dir' -- "$cur" ) ) | 109 | --perf-dir --work-tree --debugfs-dir' -- "$cur" |
105 | else | 110 | else |
106 | cmds=$($cmd --list-cmds) | 111 | cmds=$($cmd --list-cmds) |
107 | COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) ) | 112 | __perfcomp "$cmds" "$cur" |
108 | fi | 113 | fi |
109 | # List possible events for -e option | 114 | # List possible events for -e option |
110 | elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then | 115 | elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then |
111 | evts=$($cmd list --raw-dump) | 116 | evts=$($cmd list --raw-dump) |
112 | COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) | 117 | __perfcomp "$evts" "$cur" |
113 | __ltrim_colon_completions $cur | 118 | __ltrim_colon_completions $cur |
114 | # List long option names | 119 | # List long option names |
115 | elif [[ $cur == --* ]]; then | 120 | elif [[ $cur == --* ]]; then |
116 | subcmd=${words[1]} | 121 | subcmd=${words[1]} |
117 | opts=$($cmd $subcmd --list-opts) | 122 | opts=$($cmd $subcmd --list-opts) |
118 | COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) | 123 | __perfcomp "$opts" "$cur" |
119 | fi | 124 | fi |
120 | } | 125 | } |
121 | 126 | ||