2012-08-09 14:31:51 +00:00
|
|
|
# perf completion
|
|
|
|
|
|
|
|
have perf &&
|
|
|
|
_perf()
|
|
|
|
{
|
|
|
|
local cur cmd
|
|
|
|
|
|
|
|
COMPREPLY=()
|
2012-08-09 14:31:52 +00:00
|
|
|
_get_comp_words_by_ref cur prev
|
2012-08-09 14:31:51 +00:00
|
|
|
|
|
|
|
cmd=${COMP_WORDS[0]}
|
|
|
|
|
|
|
|
# List perf subcommands
|
|
|
|
if [ $COMP_CWORD -eq 1 ]; then
|
|
|
|
cmds=$($cmd --list-cmds)
|
|
|
|
COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
|
2012-08-09 14:31:52 +00:00
|
|
|
# List possible events for -e option
|
|
|
|
elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
|
|
|
|
cmds=$($cmd list --raw-dump)
|
|
|
|
COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
|
2012-08-09 14:31:51 +00:00
|
|
|
# Fall down to list regular files
|
|
|
|
else
|
|
|
|
_filedir
|
|
|
|
fi
|
|
|
|
} &&
|
|
|
|
complete -F _perf perf
|