diff options
Diffstat (limited to 'tools/perf/bash_completion')
-rw-r--r-- | tools/perf/bash_completion | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion index 5c355ababf80..56e6a12aab59 100644 --- a/tools/perf/bash_completion +++ b/tools/perf/bash_completion | |||
@@ -6,6 +6,19 @@ function_exists() | |||
6 | return $? | 6 | return $? |
7 | } | 7 | } |
8 | 8 | ||
9 | function_exists __ltrim_colon_completions || | ||
10 | __ltrim_colon_completions() | ||
11 | { | ||
12 | if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then | ||
13 | # Remove colon-word prefix from COMPREPLY items | ||
14 | local colon_word=${1%${1##*:}} | ||
15 | local i=${#COMPREPLY[*]} | ||
16 | while [[ $((--i)) -ge 0 ]]; do | ||
17 | COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} | ||
18 | done | ||
19 | fi | ||
20 | } | ||
21 | |||
9 | have perf && | 22 | have perf && |
10 | _perf() | 23 | _perf() |
11 | { | 24 | { |
@@ -13,9 +26,9 @@ _perf() | |||
13 | 26 | ||
14 | COMPREPLY=() | 27 | COMPREPLY=() |
15 | if function_exists _get_comp_words_by_ref; then | 28 | if function_exists _get_comp_words_by_ref; then |
16 | _get_comp_words_by_ref cur prev | 29 | _get_comp_words_by_ref -n : cur prev |
17 | else | 30 | else |
18 | cur=$(_get_cword) | 31 | cur=$(_get_cword :) |
19 | prev=${COMP_WORDS[COMP_CWORD-1]} | 32 | prev=${COMP_WORDS[COMP_CWORD-1]} |
20 | fi | 33 | fi |
21 | 34 | ||
@@ -35,6 +48,7 @@ _perf() | |||
35 | elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then | 48 | elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then |
36 | evts=$($cmd list --raw-dump) | 49 | evts=$($cmd list --raw-dump) |
37 | COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) | 50 | COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) |
51 | __ltrim_colon_completions $cur | ||
38 | # List long option names | 52 | # List long option names |
39 | elif [[ $cur == --* ]]; then | 53 | elif [[ $cur == --* ]]; then |
40 | subcmd=${COMP_WORDS[1]} | 54 | subcmd=${COMP_WORDS[1]} |