| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2010 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.23 2010/01/02 00:07:46 ulm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.24 2010/04/07 04:20:46 darkside Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: bash-completion.eclass |
5 | # @ECLASS: bash-completion.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # shell-tools@gentoo.org. |
7 | # shell-tools@gentoo.org. |
| 8 | # |
8 | # |
| … | |
… | |
| 11 | # @DESCRIPTION: |
11 | # @DESCRIPTION: |
| 12 | # Simple eclass that provides an interface for installing |
12 | # Simple eclass that provides an interface for installing |
| 13 | # contributed (ie not included in bash-completion proper) |
13 | # contributed (ie not included in bash-completion proper) |
| 14 | # bash-completion scripts. |
14 | # bash-completion scripts. |
| 15 | |
15 | |
| 16 | # @ECLASS-VARIABLE: BASH_COMPLETION_NAME |
16 | # @ECLASS-VARIABLE: BASHCOMPLETION_NAME |
| 17 | # @DESCRIPTION: |
17 | # @DESCRIPTION: |
| 18 | # Install the completion script with this name (see also dobashcompletion) |
18 | # Install the completion script with this name (see also dobashcompletion) |
| 19 | |
19 | |
| 20 | EXPORT_FUNCTIONS pkg_postinst |
20 | EXPORT_FUNCTIONS pkg_postinst |
| 21 | |
21 | |
| … | |
… | |
| 29 | |
29 | |
| 30 | # @FUNCTION: dobashcompletion |
30 | # @FUNCTION: dobashcompletion |
| 31 | # @USAGE: < file > [ new_file ] |
31 | # @USAGE: < file > [ new_file ] |
| 32 | # @DESCRIPTION: |
32 | # @DESCRIPTION: |
| 33 | # First arg, <file>, is required and is the location of the bash-completion |
33 | # First arg, <file>, is required and is the location of the bash-completion |
| 34 | # script to install. If the variable BASH_COMPLETION_NAME is set in the |
34 | # script to install. If the variable BASHCOMPLETION_NAME is set in the |
| 35 | # ebuild, dobashcompletion will install <file> as |
35 | # ebuild, dobashcompletion will install <file> as |
| 36 | # /usr/share/bash-completion/$BASH_COMPLETION_NAME. If it is not set, |
36 | # /usr/share/bash-completion/$BASHCOMPLETION_NAME. If it is not set, |
| 37 | # dobashcompletion will check if a second arg [new_file] was passed, installing as |
37 | # dobashcompletion will check if a second arg [new_file] was passed, installing as |
| 38 | # the specified name. Failing both these checks, dobashcompletion will |
38 | # the specified name. Failing both these checks, dobashcompletion will |
| 39 | # install the file as /usr/share/bash-completion/${PN}. |
39 | # install the file as /usr/share/bash-completion/${PN}. |
| 40 | dobashcompletion() { |
40 | dobashcompletion() { |
| 41 | [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" |
41 | [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" |
| 42 | [[ -z "${BASH_COMPLETION_NAME}" ]] && BASH_COMPLETION_NAME="${2:-${PN}}" |
42 | [[ -z "${BASHCOMPLETION_NAME}" ]] && BASHCOMPLETION_NAME="${2:-${PN}}" |
| 43 | |
43 | |
| 44 | if use bash-completion ; then |
44 | if use bash-completion ; then |
| 45 | insinto /usr/share/bash-completion |
45 | insinto /usr/share/bash-completion |
| 46 | newins "$1" "${BASH_COMPLETION_NAME}" || die "Failed to install $1" |
46 | newins "$1" "${BASHCOMPLETION_NAME}" || die "Failed to install $1" |
| 47 | fi |
47 | fi |
| 48 | } |
48 | } |
| 49 | |
49 | |
| 50 | # @FUNCTION: bash-completion_pkg_postinst |
50 | # @FUNCTION: bash-completion_pkg_postinst |
| 51 | # @DESCRIPTION: |
51 | # @DESCRIPTION: |
| … | |
… | |
| 53 | bash-completion_pkg_postinst() { |
53 | bash-completion_pkg_postinst() { |
| 54 | if use bash-completion ; then |
54 | if use bash-completion ; then |
| 55 | elog "In the case that you haven't yet enabled command-line completion" |
55 | elog "In the case that you haven't yet enabled command-line completion" |
| 56 | elog "for ${PN}, you can run:" |
56 | elog "for ${PN}, you can run:" |
| 57 | elog |
57 | elog |
| 58 | elog " eselect bashcomp enable ${BASH_COMPLETION_NAME:-${PN}}" |
58 | elog " eselect bashcomp enable ${BASHCOMPLETION_NAME:-${PN}}" |
| 59 | elog |
59 | elog |
| 60 | elog "to install locally, or" |
60 | elog "to install locally, or" |
| 61 | elog |
61 | elog |
| 62 | elog " eselect bashcomp enable --global ${BASH_COMPLETION_NAME:-${PN}}" |
62 | elog " eselect bashcomp enable --global ${BASHCOMPLETION_NAME:-${PN}}" |
| 63 | elog |
63 | elog |
| 64 | elog "to install system-wide." |
64 | elog "to install system-wide." |
| 65 | fi |
65 | fi |
| 66 | } |
66 | } |