Jump to content
Read the Funtoo Newsletter: Summer 2023 ×

how to write bash completion modules


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:



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

    # array storing the possible completions

    # define cur and prev

    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
  • Create New...