View previous topic :: View next topic |
Author |
Message |
causes n00b
Joined: 24 Sep 2014 Posts: 9 Location: Finland
|
Posted: Mon Sep 29, 2014 12:14 pm Post subject: How to create modules for app-shells/bash-completion |
|
|
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 |
|
|
i92guboj Bodhisattva
Joined: 30 Nov 2004 Posts: 10315 Location: Córdoba (Spain)
|
Posted: Mon Sep 29, 2014 12:30 pm Post subject: |
|
|
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 |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Mon Sep 29, 2014 7:02 pm Post subject: Re: How to create modules for app-shells/bash-completion |
|
|
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 |
|
|
causes n00b
Joined: 24 Sep 2014 Posts: 9 Location: Finland
|
Posted: Fri Oct 03, 2014 12:00 pm Post subject: |
|
|
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 |
|
|
gotyaoi Tux's lil' helper
Joined: 01 Apr 2013 Posts: 137
|
Posted: Fri Oct 03, 2014 7:13 pm Post subject: |
|
|
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 |
|
|
causes n00b
Joined: 24 Sep 2014 Posts: 9 Location: Finland
|
Posted: Fri Oct 03, 2014 8:57 pm Post subject: |
|
|
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 |
|
|
|