bash_completion 542 B

1234567891011121314151617181920212223242526
  1. # perf completion
  2. have perf &&
  3. _perf()
  4. {
  5. local cur cmd
  6. COMPREPLY=()
  7. _get_comp_words_by_ref cur prev
  8. cmd=${COMP_WORDS[0]}
  9. # List perf subcommands
  10. if [ $COMP_CWORD -eq 1 ]; then
  11. cmds=$($cmd --list-cmds)
  12. COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
  13. # List possible events for -e option
  14. elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
  15. cmds=$($cmd list --raw-dump)
  16. COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
  17. # Fall down to list regular files
  18. else
  19. _filedir
  20. fi
  21. } &&
  22. complete -F _perf perf