Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to create modules for app-shells/bash-completion
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
causes
n00b
n00b


Joined: 24 Sep 2014
Posts: 9
Location: Finland

PostPosted: Mon Sep 29, 2014 12:14 pm    Post subject: How to create modules for app-shells/bash-completion Reply with quote

Hi. I would like to create bash completion for sys-power/cpupower. How can i make bash completions? Is there any guide for that? Do i need to create ebuild for the module or can i submit it to be added to bash-completion ebuild?
_________________
http://causes.fi/
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Mon Sep 29, 2014 12:30 pm    Post subject: Reply with quote

The upstream for bash-completion is this:

http://bash-completion.alioth.debian.org/

So, if you want to improve it and want them to be upstreamed and packaged along with the bash-completion package then you should get in contact with them.

Yes, it could be added to the ebuild as a patch or something, but Gentoo developers prefer to remain as close as possible to upstream, unless it's for a very good reason. So I guess that's the place you should be aiming at.
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Mon Sep 29, 2014 7:02 pm    Post subject: Re: How to create modules for app-shells/bash-completion Reply with quote

causes wrote:
How can i make bash completions? Is there any guide for that?

Try this article (and the follow-up.)

There's also the #bash-completion channel on IRC: irc.oftc.net
Back to top
View user's profile Send private message
causes
n00b
n00b


Joined: 24 Sep 2014
Posts: 9
Location: Finland

PostPosted: Fri Oct 03, 2014 12:00 pm    Post subject: Reply with quote

I created bash-completion file to /etc/bash_completion.d but i it doesn't work or appear on eselect bashcomp list? How can i make it work on gentoo

/etc/bash_completion.d/cpupower
Code:

_cpupower()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="frequency-info frequency-set idle-info idle-set set info monitor help"

    if [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
}
complete -F _cpupower cpupower


EDIT:
Now it shows up in eselect bashcomp when i moved it to /usr/share/bash-completion/completions but it doesn't work?
_________________
http://causes.fi/
Back to top
View user's profile Send private message
gotyaoi
Tux's lil' helper
Tux's lil' helper


Joined: 01 Apr 2013
Posts: 137

PostPosted: Fri Oct 03, 2014 7:13 pm    Post subject: Reply with quote

It's your if statement. The "if [[ ${cur} == -* ]] ; then " says to only try and complete things if they start with a dash. You can probably just get rid of the if and fi lines and have the COMPREPLY and the return with the rest of the code.
Back to top
View user's profile Send private message
causes
n00b
n00b


Joined: 24 Sep 2014
Posts: 9
Location: Finland

PostPosted: Fri Oct 03, 2014 8:57 pm    Post subject: Reply with quote

gotyaoi wrote:
It's your if statement. The "if [[ ${cur} == -* ]] ; then " says to only try and complete things if they start with a dash. You can probably just get rid of the if and fi lines and have the COMPREPLY and the return with the rest of the code.

Thanks! It's working now :-)
_________________
http://causes.fi/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum