diff options
author | Aron Griffis <agriffis@gentoo.org> | 2006-11-22 17:33:51 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2006-11-22 17:33:51 +0000 |
commit | 1f725eda4188246601925a3dd4ffc199d0fc1d10 (patch) | |
tree | d2ebdab59c52307475ae7fdc9da08474d150195e /sys-kernel/genkernel/files | |
parent | ppc stable, bug #155654 (diff) | |
download | gentoo-2-1f725eda4188246601925a3dd4ffc199d0fc1d10.tar.gz gentoo-2-1f725eda4188246601925a3dd4ffc199d0fc1d10.tar.bz2 gentoo-2-1f725eda4188246601925a3dd4ffc199d0fc1d10.zip |
Add bash-completion #72845
(Portage version: 2.1.2_pre3-r1)
Diffstat (limited to 'sys-kernel/genkernel/files')
-rw-r--r-- | sys-kernel/genkernel/files/digest-genkernel-3.4.5-r1 | 21 | ||||
-rw-r--r-- | sys-kernel/genkernel/files/genkernel.bash | 73 |
2 files changed, 94 insertions, 0 deletions
diff --git a/sys-kernel/genkernel/files/digest-genkernel-3.4.5-r1 b/sys-kernel/genkernel/files/digest-genkernel-3.4.5-r1 new file mode 100644 index 000000000000..982c3b3a546b --- /dev/null +++ b/sys-kernel/genkernel/files/digest-genkernel-3.4.5-r1 @@ -0,0 +1,21 @@ +MD5 87d8615a655b9a6c1a0e234eab2485bf LVM2.2.02.05.tgz 473621 +RMD160 7295f14e64dc25035d46e3512db6cae1b2be5f9b LVM2.2.02.05.tgz 473621 +SHA256 707c596c7a2f11cc08d3b1099995be2a4a3859a5454ed5af1a6c5361a821a402 LVM2.2.02.05.tgz 473621 +MD5 460cc211b03af4048ec90c0de2ecd8f7 device-mapper.1.02.07.tgz 923923 +RMD160 517dd7bde6935235f8c22149ef6e0cb80e6c925b device-mapper.1.02.07.tgz 923923 +SHA256 1e9c16e8f7bcf87bec03103dda63c0d11cdc739f432488b026b4614fd3cabf40 device-mapper.1.02.07.tgz 923923 +MD5 a2a8948de7717e2e76a1291fc1daf9d1 dmraid-1.0.0.rc13.tar.bz2 170497 +RMD160 9b95d68c2177c3bb7c74227c375780d3b4936ef7 dmraid-1.0.0.rc13.tar.bz2 170497 +SHA256 8497196528d50203053de0f733917b1d85aae416d2136c695a07aee5632b12b9 dmraid-1.0.0.rc13.tar.bz2 170497 +MD5 d774d4412bfb80d12cf3a4fdfd59de5a e2fsprogs-1.38.tar.gz 3621193 +RMD160 492071c29e9a0adc1bed0762e795efb6b29a692c e2fsprogs-1.38.tar.gz 3621193 +SHA256 c4e482687d0cff240d02a70fcf423cc14296b6a7869cd8dd42d5404d098e0bb7 e2fsprogs-1.38.tar.gz 3621193 +MD5 2cc4f6f0807b9031b7438d86bd4f384d genkernel-3.4.5.tar.bz2 164968 +RMD160 0d0bbb4a6aea100d526c86f5fe3db80d8eb5c4e7 genkernel-3.4.5.tar.bz2 164968 +SHA256 8d0e10a07e8edd143f35a40e73a594061d5d67761ac0fa9c46c21943a8b50108 genkernel-3.4.5.tar.bz2 164968 +MD5 2fa8384b099d53f878a1f8ef49214493 genkernel-pkg-3.4.tar.bz2 1848904 +RMD160 09e1baed7e3703b2f6c304656a81a12ba4594083 genkernel-pkg-3.4.tar.bz2 1848904 +SHA256 2345a16a3b377e3ffde2f0cca7e82cf3566e03e8bb2098db69210f505a989af3 genkernel-pkg-3.4.tar.bz2 1848904 +MD5 38ed4d9e41c20cf398018928d2c62700 unionfs-1.4.tar.gz 164696 +RMD160 5a19ccfd6edf25f55c48ba1b820347572353c7ba unionfs-1.4.tar.gz 164696 +SHA256 3ff105782aba722b1f263e408fac638245d302a9c8d0f37ac09e5a80caf0126b unionfs-1.4.tar.gz 164696 diff --git a/sys-kernel/genkernel/files/genkernel.bash b/sys-kernel/genkernel/files/genkernel.bash new file mode 100644 index 000000000000..bb326c87d3a9 --- /dev/null +++ b/sys-kernel/genkernel/files/genkernel.bash @@ -0,0 +1,73 @@ +# genkernel (8) completion +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Written by Aron Griffis <agriffis@gentoo.org> + +_genkernel() +{ + declare cur prev genkernel_help actions params + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + # extract initial list of params/actions from genkernel --help + genkernel_help=$(command genkernel --help) + actions=( $(<<<"$genkernel_help" sed -n \ + '/^Available Actions:/,/^$/s/^[[:space:]]\+\([^[:space:]]\+\).*/\1/p') ) + params=( $(<<<"$genkernel_help" egrep -oe '--[^[:space:]]{2,}') ) + + # attempt to complete the current parameter based on the list + COMPREPLY=($(compgen -W "${params[*]/=*/=} ${actions[*]}" -- "$cur")) + + # if we don't have a rhs to complete + if [[ ${#COMPREPLY[@]} -gt 1 ]]; then + return + elif [[ ${#COMPREPLY[@]} -eq 0 && $cur != --*=* ]]; then + return + elif [[ ${#COMPREPLY[@]} -eq 1 && $COMPREPLY != --*= ]]; then + # using nospace completion, add an explicit space + COMPREPLY="${COMPREPLY} " + return + fi + + # we have a unique lhs and need to complete the rhs + declare args lhs rhs + if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + lhs=$COMPREPLY + else + lhs=${cur%%=*}= + rhs=${cur#*=} + fi + + # genkernel's help gives clues as to what belongs on the rhs. + # extract the clue for the current parameter + args=" ${params[*]} " + args="${args##* $lhs}" + args="${args%% *}" + + # generate a list of completions for the argument; this replaces args with + # an array of results + args=( $(case $args in + ('<0-5>') compgen -W "$(echo {1..5})" -- "$rhs" ;; + ('<outfile>'|'<file>') compgen -A file -o plusdirs -- "$rhs" ;; + ('<dir>') compgen -A directory -S / -- "$rhs" ;; + ('<tbz2>') compgen -G '*.tbz2' -G '*.tar.bz2' -o plusdirs -- "$rhs" ;; + (*) compgen -o bashdefault -- "$rhs" ;; # punt + esac) ) + + # we're using nospace completion to prevent spaces after paths that aren't + # "done" yet. So do some hacking to the args to add spaces after + # non-directories. + declare slash=/ + args=( "${args[@]/%/ }" ) # add space to all + args=( "${args[@]/%$slash /$slash}" ) # remove space from dirs + + # recreate COMPREPLY + if [[ $cur == "$lhs"* ]]; then + COMPREPLY=( "${args[@]}" ) + else + COMPREPLY=( "${args[@]/#/$lhs}" ) + fi +} + +complete -o nospace -F _genkernel genkernel |