[Pkg-bazaar-commits] ./bzr/unstable r620: - Improved bash completion script
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:26 UTC 2009
------------------------------------------------------------
revno: 620
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Thu 2005-06-02 12:41:33 +1000
message:
- Improved bash completion script
contributed by Sven Wilhelm
added:
contrib/bash/bzr
renamed:
contrib/bash/bzr => contrib/bash/bzr.simple
-------------- next part --------------
=== added file 'contrib/bash/bzr'
--- a/contrib/bash/bzr 1970-01-01 00:00:00 +0000
+++ b/contrib/bash/bzr 2005-06-02 02:41:33 +0000
@@ -0,0 +1,104 @@
+# Programmable completion for the Bazaar-NG bzr command under bash. Source
+# this file (or on some systems add it to ~/.bash_completion and start a new
+# shell) and bash's completion mechanism will know all about bzr's options!
+
+# Known to work with bash 2.05a with programmable completion and extended
+# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
+# these if they are not already enabled).
+
+# Based originally on the svn bash completition script.
+# Customized by Sven Wilhelm/Icecrash.com
+
+_bzr ()
+{
+ local cur cmds cmdOpts opt helpCmds optBase i
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ cmds='status diff commit ci checkin move remove log info check ignored'
+
+ if [[ $COMP_CWORD -eq 1 ]] ; then
+ COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
+ return 0
+ fi
+
+ # if not typing an option, or if the previous option required a
+ # parameter, then fallback on ordinary filename expansion
+ helpCmds='help|--help|h|\?'
+ if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
+ [[ "$cur" != -* ]] ; then
+ return 0
+ fi
+
+ cmdOpts=
+ case ${COMP_WORDS[1]} in
+ status)
+ cmdOpts="--all --show-ids"
+ ;;
+ diff)
+ cmdOpts="-r --revision --diff-options"
+ ;;
+ commit|ci|checkin)
+ cmdOpts="-r --message -F --file -v --verbose"
+ ;;
+ move)
+ cmdOpts=""
+ ;;
+ remove)
+ cmdOpts="-v --verbose"
+ ;;
+ log)
+ cmdOpts="--forward --timezone -v --verbose --show-ids -r --revision"
+ ;;
+ info)
+ cmdOpts=""
+ ;;
+ ignored)
+ cmdOpts=""
+ ;;
+ check)
+ cmdOpts=""
+ ;;
+ help|h|\?)
+ cmdOpts="$cmds $qOpts"
+ ;;
+ *)
+ ;;
+ esac
+
+ cmdOpts="$cmdOpts --help -h"
+
+ # take out options already given
+ for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do
+ opt=${COMP_WORDS[$i]}
+
+ case $opt in
+ --*) optBase=${opt/=*/} ;;
+ -*) optBase=${opt:0:2} ;;
+ esac
+
+ cmdOpts=" $cmdOpts "
+ cmdOpts=${cmdOpts/ ${optBase} / }
+
+ # take out alternatives
+ case $optBase in
+ -v) cmdOpts=${cmdOpts/ --verbose / } ;;
+ --verbose) cmdOpts=${cmdOpts/ -v / } ;;
+ -h) cmdOpts=${cmdOpts/ --help / } ;;
+ --help) cmdOpts=${cmdOpts/ -h / } ;;
+ -r) cmdOpts=${cmdOpts/ --revision / } ;;
+ --revision) cmdOpts=${cmdOpts/ -r / } ;;
+ esac
+
+ # skip next option if this one requires a parameter
+ if [[ $opt == @($optsParam) ]] ; then
+ ((++i))
+ fi
+ done
+
+ COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
+
+ return 0
+}
+complete -F _bzr -o default bzr
=== renamed file 'contrib/bash/bzr' => 'contrib/bash/bzr.simple'
More information about the Pkg-bazaar-commits
mailing list