Rev 33 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# perf completionfunction_exists(){declare -F $1 > /dev/nullreturn $?}function_exists __ltrim_colon_completions ||__ltrim_colon_completions(){if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then# Remove colon-word prefix from COMPREPLY itemslocal colon_word=${1%${1##*:}}local i=${#COMPREPLY[*]}while [[ $((--i)) -ge 0 ]]; doCOMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}donefi}have perf &&_perf(){local cur prev cmdCOMPREPLY=()if function_exists _get_comp_words_by_ref; then_get_comp_words_by_ref -n : cur prevelsecur=$(_get_cword :)prev=${COMP_WORDS[COMP_CWORD-1]}ficmd=${COMP_WORDS[0]}# List perf subcommands or long optionsif [ $COMP_CWORD -eq 1 ]; thenif [[ $cur == --* ]]; thenCOMPREPLY=( $( compgen -W '--help --version \--exec-path --html-path --paginate --no-pager \--perf-dir --work-tree --debugfs-dir' -- "$cur" ) )elsecmds=$($cmd --list-cmds)COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )fi# List possible events for -e optionelif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; thenevts=$($cmd list --raw-dump)COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )__ltrim_colon_completions $cur# List long option nameselif [[ $cur == --* ]]; thensubcmd=${COMP_WORDS[1]}opts=$($cmd $subcmd --list-opts)COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )# Fall down to list regular fileselse_filedirfi} &&complete -F _perf perf