Index: bash_completion =================================================================== --- bash_completion (revision 24559) +++ bash_completion (working copy) @@ -10,6 +10,13 @@ shopt -s extglob +# Remove : from the list of completion word breaks +# This is used to enable URL completion below +# Note that this was introduced after bash 2.05a, so there's a check +# in the URL completion code to do this one of two ways, depending +# on the existence of this variable +COMP_WORDBREAKS=${COMP_WORDBREAKS//:} + # This completion guides the command/option order along the one suggested # by "svn help", although other syntaxes are allowed. # @@ -426,7 +433,50 @@ # if not typing an option, # then fallback on ordinary filename expansion if [[ $cur != -* || $stat = 'onlyarg' ]] ; then - return 0 + if [ -z $COMP_WORDBREAKS ]; then + + # if argument is an svn directory + if [[ $cur == svn://*/ ]] ; then + # strip leading svn: due to completion issues with : + cur_path=${cur/svn:/} + # query server and then prepend stripped path + ls_results=`svn ls $cur | sed s@^@$cur_path@g` + COMPREPLY=( $(compgen -W "$ls_results" -- "$cur_path") ) + return 0 + fi + + # if argument is an http directory + if [[ $cur == http://*/ ]] ; then + # strip leading http: due to completion issues with : + cur_path=${cur/http:/} + # query server and then prepend stripped path + ls_results=`svn ls $cur | sed s@^@$cur_path@g` + COMPREPLY=( $(compgen -W "$ls_results" -- "$cur_path") ) + return 0 + fi + + else + + # if argument is an svn url + if [[ $cur == svn://* ]] ; then + # strip to last slash + cur_trunk=`echo $cur | sed 's@\(.*\)/.*@\1@'` + # query server and then prepend stripped path + ls_results=`svn ls $cur_trunk | sed "s@\(.*\)@$cur_trunk/\1@g"` + COMPREPLY=( $(compgen -o nospace -W "$ls_results" "$cur") ) + return 0 + fi + + if [[ $cur == http://* ]] ; then + # strip to last slash + cur_trunk=`echo $cur | sed 's@\(.*\)/.*@\1@'` + # query server and then prepend stripped path + ls_results=`svn ls $cur_trunk | sed "s@\(.*\)@$cur_trunk/\1@g"` + COMPREPLY=( $(compgen -o nospace -W "$ls_results" "$cur") ) + return 0 + fi + fi + return 0 fi # otherwise build possible options for the command