Frederic Weisbecker | 98a4179 | 2012-08-09 16:31:51 +0200 | [diff] [blame] | 1 | # perf completion |
| 2 | |
| 3 | have perf && |
| 4 | _perf() |
| 5 | { |
| 6 | local cur cmd |
| 7 | |
| 8 | COMPREPLY=() |
Frederic Weisbecker | a3277d2 | 2012-08-09 16:31:52 +0200 | [diff] [blame^] | 9 | _get_comp_words_by_ref cur prev |
Frederic Weisbecker | 98a4179 | 2012-08-09 16:31:51 +0200 | [diff] [blame] | 10 | |
| 11 | cmd=${COMP_WORDS[0]} |
| 12 | |
| 13 | # List perf subcommands |
| 14 | if [ $COMP_CWORD -eq 1 ]; then |
| 15 | cmds=$($cmd --list-cmds) |
| 16 | COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) ) |
Frederic Weisbecker | a3277d2 | 2012-08-09 16:31:52 +0200 | [diff] [blame^] | 17 | # List possible events for -e option |
| 18 | elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then |
| 19 | cmds=$($cmd list --raw-dump) |
| 20 | COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) ) |
Frederic Weisbecker | 98a4179 | 2012-08-09 16:31:51 +0200 | [diff] [blame] | 21 | # Fall down to list regular files |
| 22 | else |
| 23 | _filedir |
| 24 | fi |
| 25 | } && |
| 26 | complete -F _perf perf |