1
# Programmable completion for the Bazaar-NG bzr command under bash. Source
 
 
2
# this file (or on some systems add it to ~/.bash_completion and start a new
 
 
3
# shell) and bash's completion mechanism will know all about bzr's options!
 
 
5
# Known to work with bash 2.05a with programmable completion and extended
 
 
6
# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
 
 
7
# these if they are not already enabled).
 
 
9
# Based originally on the svn bash completition script.
 
 
10
# Customized by Sven Wilhelm/Icecrash.com
 
 
14
        local cur cmds cmdOpts opt helpCmds optBase i
 
 
17
        cur=${COMP_WORDS[COMP_CWORD]}
 
 
19
        cmds='status diff commit ci checkin move remove log info check ignored'
 
 
21
        if [[ $COMP_CWORD -eq 1 ]] ; then
 
 
22
                COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
 
 
26
        # if not typing an option, or if the previous option required a
 
 
27
        # parameter, then fallback on ordinary filename expansion
 
 
28
        helpCmds='help|--help|h|\?'
 
 
29
        if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
 
 
30
           [[ "$cur" != -* ]] ; then
 
 
35
        case ${COMP_WORDS[1]} in
 
 
37
                cmdOpts="--all --show-ids"
 
 
40
                cmdOpts="-r --revision --diff-options"
 
 
43
                cmdOpts="-r --message -F --file -v --verbose"
 
 
49
                cmdOpts="-v --verbose"
 
 
52
                cmdOpts="--forward --timezone -v --verbose --show-ids -r --revision"
 
 
64
                cmdOpts="$cmds $qOpts"
 
 
70
        cmdOpts="$cmdOpts --help -h"
 
 
72
        # take out options already given
 
 
73
        for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do
 
 
77
                --*)    optBase=${opt/=*/} ;;
 
 
78
                -*)     optBase=${opt:0:2} ;;
 
 
82
                cmdOpts=${cmdOpts/ ${optBase} / }
 
 
84
                # take out alternatives
 
 
86
                -v)              cmdOpts=${cmdOpts/ --verbose / } ;;
 
 
87
                --verbose)       cmdOpts=${cmdOpts/ -v / } ;;
 
 
88
                -h)              cmdOpts=${cmdOpts/ --help / } ;;
 
 
89
                --help)          cmdOpts=${cmdOpts/ -h / } ;;
 
 
90
                -r)              cmdOpts=${cmdOpts/ --revision / } ;;
 
 
91
                --revision)      cmdOpts=${cmdOpts/ -r / } ;;
 
 
94
                # skip next option if this one requires a parameter
 
 
95
                if [[ $opt == @($optsParam) ]] ; then
 
 
100
        COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
 
 
104
complete -F _bzr -o default bzr