Jump to content
Forums in Read-Only Mode - Please use Reddit ×

how to write bash completion modules


causes

Recommended Posts

I would like to learn to write bash completion modules. The available documentation is poor. So i would like to get help writing completion for cpupower. I already have completion for first argument working. Next i would like to get completion for -g <governor> working. Please reply if you can help me :-).

 

Here is what i have already:

/usr/share/bash-completion/completions/cpupower

 

_cpupower() {
    # pointer to current and prev completion word
    local cur prev
    # completion options
    local opts

    # array storing the possible completions
    COMPREPLY=()

    # define cur and prev
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    opts="frequency-info frequency-set idle-info idle-set set info monitor help"

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}

complete -F _cpupower cpupower
Link to comment
Share on other sites

×
×
  • Create New...