contrib/zsh_completion
changeset 3598 27121416f9a8
parent 3597 0d253ec988a6
child 3600 932dadd2e614
--- a/contrib/zsh_completion	Tue Oct 31 12:05:47 2006 -0800
+++ b/contrib/zsh_completion	Tue Oct 31 14:53:08 2006 -0800
@@ -163,10 +163,33 @@
     'files:missing files:_hg_missing'
 }
 
+_hg_ssh_urls() {
+  if [[ -prefix */ ]]
+  then
+    if zstyle -T ":completion:${curcontext}:files" remote-access
+    then
+      local host=${PREFIX%%/*}
+      typeset -a remdirs
+      compset -p $(( $#host + 1 ))
+      local rempath=${(M)PREFIX##*/}
+      compset -P '*/'
+      remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/})
+      _describe -t directories 'remote directory' remdirs -S/
+    else
+      _message 'remote directory'
+    fi
+  else
+    _hosts -S/
+  fi
+}
+
 _hg_urls() {
   if compset -P bundle://
   then
     _files
+  elif compset -P ssh://
+  then
+    _hg_ssh_urls
   elif [[ -prefix *: ]]
   then
     _urls
@@ -190,7 +213,7 @@
 _hg_remote() {
   _alternative 'path-aliases:repository alias:_hg_paths' \
     'directories:directory:_files -/' \
-    'urls:URL schema:_hg_urls'
+    'urls:URL:_hg_urls'
 }
 
 # Common options