Alpha of subversion URL tab completion 3
Despite how much I really hate shell scripting I’ve actually got something semi-functional going on this whole svn tab completion idea. It only does anything when you tab on a full directory path (http://youserver/ or http://youserver/foo), but it will list the possibilities when you do, and autocomplete if there is only one.
I guess that just leaves getting partial completion working, ie http://yourserver/fo => http://yourserver/foo/, and then it’s done. I’m happy just to have it this far, though, so I won’t be cranking that out immediately. Down the road a bit maybe I’ll think about hostname completion too.
I cover the prerequisites in my quick intro to bash_completion of OS X. If you have that installed and the lastest svn bash_completion file, then you can just apply my patch.
bash_completion.patch.txt | bash_completion.patch
Index: bash_completion
===================================================================
--- bash_completion (revision 24040)
+++ bash_completion (working copy)
@@ -423,10 +423,19 @@
return 0
fi
- # if not typing an option,
- # then fallback on ordinary filename expansion
+ # if not typing an option
if [[ $cur != -* || $stat = 'onlyarg' ]] ; then
- return 0
+ # 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
+ # fallback on ordinary filename expansion
+ return 0
fi
# otherwise build possible options for the command
@@ -722,3 +731,4 @@
return 0
}
complete -F _svnadmin -o default svnadmin
+

Articles via rss or email
# if not typing an option, # then fallback on ordinary filename expansion # if argument is an URL if [[ $cur == *:/* ]] ; then # strip leading protocol due to completion issues with : cur_path=${cur/*:/} # query server and then prepend stripped path - add . to paths so that # if they're real directories we get them i.e. dir/ -> dir/. -> dir ls_results=`svn ls $(dirname $cur.) 2> /dev/null | sed -e "s@^@$(dirname $cur_path.)/@"` COMPREPLY=( $(compgen -W "$ls_results" -- "$cur_path") ) return 0 fi # fallback on ordinary filename expansion _filedir return 0with:Nice! I’ll have to check this out, Dan.
Thanks for sharing these patches, Tim & Dan. Very handy when I can’t remember paths in old project repositories.