[2.30,devel] Updated to new postr repository (GNOME bug 609368)
[jhbuild.git] / contrib / jhbuild_completion.bash
blobd70e88e14cee5eebfcecd51b9f6a72912a16b052
1 #!/bin/bash
3 # jhbuild tab completion for bash.
4 # (c) 2004, Davyd Madeley <davyd@ucc.asn.au>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # To use this completion function simply source this file into your bashrc
21 # with:
22 # . ~/path/to/jhbuild/contrib/jhbuild_completion.bash
23 # This completion function depends on helper functions from the main set of
24 # bash completions, ensure you've sourced /etc/bash_completion before sourcing
25 # this file.
28 _jhbuild()
30 local cur prev command_list i v
32 cur=${COMP_WORDS[COMP_CWORD]}
33 prev=${COMP_WORDS[COMP_CWORD-1]}
35 case "$prev" in
36 gui|tinderbox|shell|sanitycheck|bootstrap)
37 command_list=""
39 update|updateone|build|buildone|list|dot|info|-t|-s|-a|-n|-c)
40 # FIXME: some of these options can take multiple module names
41 # give them a list of modules
42 command_list="`jhbuild list -a`"
44 run)
45 # give them a list of commands
46 COMP_WORDS=(COMP_WORDS[0] $cur)
47 COMP_CWORD=1
48 _command
50 -f|-m)
51 # give them file completion
52 _filedir
54 -o)
55 # give them directory completion
56 _filedir -d
59 command_list="gui update updateone build buildone tinderbox run shell sanitycheck bootstrap list dot info"
61 v=false
62 if [ $COMP_CWORD -gt 2 ]; then
63 for i in $command_list; do
64 if [ "${COMP_WORDS[COMP_CWORD-2]}" == "$i" ]; then
65 v=true
66 break
68 done
71 if $v; then
72 command_list=""
75 esac
77 for i in $command_list; do
78 if [ -z "${i/$cur*}" ]; then
79 COMPREPLY=( ${COMPREPLY[@]} $i )
81 done
84 # load the completion
85 complete -F _jhbuild jhbuild