Index: bash_completion =================================================================== --- bash_completion (revision 24587) +++ 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,6 +433,54 @@ # if not typing an option, # then fallback on ordinary filename expansion if [[ $cur != -* || $stat = 'onlyarg' ]] ; then + if [ -z $COMP_WORDBREAKS ]; then + + # if argument is an svn url + 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 --non-interactive ls $cur | \ + sed -e s@^@$cur_path@g` + COMPREPLY=( $(compgen -W "$ls_results" -- "$cur_path") ) + return 0 + fi + + # if argument is an http url + 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 --non-interactive ls $cur | \ + sed -e 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 --non-interactive ls $cur_trunk | \ + sed -e "s@\(.*\)@$cur_trunk/\1@g"` + COMPREPLY=( $(compgen -W "$ls_results" "$cur") ) + return 0 + fi + + # if argument is an http url + 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 --non-interactive ls $cur_trunk | \ + sed -e "s@\(.*\)@$cur_trunk/\1@g"` + COMPREPLY=( $(compgen -W "$ls_results" "$cur") ) + return 0 + fi + fi return 0 fi @@ -620,7 +675,7 @@ COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } -complete -F _svn -f -X '@(*/.svn|.svn)' svn +complete -F _svn -f -X '@(*/.svn|.svn)' -o nospace svn _svnadmin () {