5f92be
# Use git-annex's built-in bash completion
5f92be
# This bash completion is generated by the option parser, so it covers all
5f92be
# commands, all options, and will never go out of date!
5f92be
_git-annex()
5f92be
{
e8d081
    local CMDLINE
e8d081
    local IFS=$'\n'
5f92be
    CMDLINE=(--bash-completion-index $COMP_CWORD)
5f92be
5f92be
    for arg in ${COMP_WORDS[@]}; do
5f92be
        CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
5f92be
    done
5f92be
5f92be
    COMPREPLY=( $(git-annex "${CMDLINE[@]}") )
5f92be
}
5f92be
5f92be
complete -o bashdefault -o default -o filenames -F _git-annex git-annex
5f92be
5f92be
# Called by git's bash completion script when completing "git annex"
5f92be
_git_annex() {
5f92be
    local cmdline
5f92be
    CMDLINE=(--bash-completion-index $(($COMP_CWORD - 1)))
5f92be
5f92be
    local seen_git
5f92be
    local seen_annex
5f92be
    for arg in ${COMP_WORDS[@]}; do
5f92be
        if [ "$arg" = git ] && [ -z "$seen_git" ]; then
5f92be
		seen_git=1
5f92be
		CMDLINE=(${CMDLINE[@]} --bash-completion-word git-annex)
5f92be
	elif [ "$arg" = annex ] && [ -z "$seen_annex" ]; then
5f92be
		seen_annex=1
5f92be
	else
5f92be
		CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
5f92be
	fi
5f92be
    done
5f92be
5f92be
    COMPREPLY=( $(git-annex "${CMDLINE[@]}") )
5f92be
}