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
1
# Copyright (C) 2010 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
# Programmable completion for the Bazaar-NG bzr command under bash.
18
# Source this file (or add it to your ~/.bash_completion or ~/.bashrc
19
# file, depending on your system configuration, and start a new shell)
20
# and bash's completion mechanism will know all about bzr's options!
22
# This completion function assumes you have the bzr-bash-completion
23
# plugin installed as a bzr plugin. It will generate the full
24
# completion function at first invocation, thus avoiding long delays
25
# for every shell you start.
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 ) )
31
eval "$(bzr bash-completion)"
32
if [[ $(type -t _bzr) == function ]]; then
104
complete -F _bzr -o default bzr
40
complete -F _bzr_lazy -o default bzr