the bash-completer for bazaar was one of the easiest i ever got working!
this is due to the builtin support for it, although it might better suit
the zsh. --clemens
# scans args, returns 1st non-option or 1 if none
__get_1st_nonopt()
{
_1st_nonopt=""
shift
for i in "$@"
do
case "$i" in
--)
return 1
;;
-*)
;;
*) _1st_nonopt="$i"
return 0
;;
esac
done
return 1
}
#
_bzr_commands()
{
bzr s-c | sed -nE 's/^([^:]+):.*/\1/p'
}
_bzr_opts()
{
bzr s-c "$1" | sed -nE 's/^.+(--[[:alnum:]_-]+).*/\1/p'
bzr s-c "$1" | sed -nE 's/^.+(-[[:alnum:]]+).*/\1/p'|grep -v -- '-None'
}
_bzr()
{
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ".${cur}" in
.-*)
__get_1st_nonopt "${COMP_WORDS[@]}" || : 'COMPREPLY=( $(compgen -f $cur) )'
COMPREPLY=( $(compgen -W "$(_bzr_opts ${_1st_nonopt})" -- $cur) )
;;
.*)
case "$prev" in
--) COMPREPLY=( $(compgen -f -- $cur) )
;;
bzr) COMPREPLY=( $(compgen -W "$(_bzr_commands)" -- $cur))
;; help|\?|--help|-\?|-h) COMPREPLY=( $(compgen -W "$(_bzr_commands)" -- $cur) $(compgen -W "$(bzr help topics | sed -nE 's/^([^[:space:]]+).*/\1/p')" -- $cur) )
;;
esac
;;
esac
}
complete -F _bzr -o default bzr
the bash-completer for bazaar was one of the easiest i ever got working!
this is due to the builtin support for it, although it might better suit
the zsh. --clemens
# scans args, returns 1st non-option or 1 if none
_1st_nonopt= "$i" :]+):.* /\1/p' --[[:alnum: ]_-]+). */\1/p' -[[:alnum: ]]+).*/ \1/p'|grep -v -- '-None' {COMP_WORDS[ COMP_CWORD] } ${COMP_ WORDS[COMP_ CWORD-1] } _get_1st_ nonopt "${COMP_WORDS[@]}" || : 'COMPREPLY=( $(compgen -f $cur) )'
COMPREPLY= ( $(compgen -f -- $cur) )
COMPREPLY= ( $(compgen -W "$(_bzr_commands)" -- $cur))
help|\ ?|--help| -\?|-h)
COMPREPLY= ( $(compgen -W "$(_bzr_commands)" -- $cur)
$( compgen -W "$(bzr help topics | sed -nE 's/^([^ [:space: ]]+).*/ \1/p')" -- $cur) )
__get_1st_nonopt()
{
_1st_nonopt=""
shift
for i in "$@"
do
case "$i" in
--)
return 1
;;
-*)
;;
*)
return 0
;;
esac
done
return 1
}
#
_bzr_commands()
{
bzr s-c | sed -nE 's/^([^
}
_bzr_opts()
{
bzr s-c "$1" | sed -nE 's/^.+(
bzr s-c "$1" | sed -nE 's/^.+(
}
_bzr()
{
cur=$
prev=
case ".${cur}" in
.-*)
_
COMPREPLY=( $(compgen -W "$(_bzr_opts ${_1st_nonopt})" -- $cur) )
;;
.*)
case "$prev" in
--)
;;
bzr)
;;
;;
esac
;;
esac
}
complete -F _bzr -o default bzr