Jump to content

how to write bash completion modules


causes
 Share

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 an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...