summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:42:54 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:42:54 +0000
commit88be4ff8500895ad5063c8d17798aa23d3aee84e (patch)
tree67d138b05d5a56ccccbcea8290f66325e20c91cc
parente4b24d44205417e4b5f6b141226515c65d03eb0f (diff)
downloadzsh-88be4ff8500895ad5063c8d17798aa23d3aee84e.tar.gz
zsh-88be4ff8500895ad5063c8d17798aa23d3aee84e.tar.xz
zsh-88be4ff8500895ad5063c8d17798aa23d3aee84e.zip
moved from Completion/User/_tilde_files
-rw-r--r--Completion/Unix/Type/_tilde_files38
1 files changed, 38 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_tilde_files b/Completion/Unix/Type/_tilde_files
new file mode 100644
index 000000000..ee6b18088
--- /dev/null
+++ b/Completion/Unix/Type/_tilde_files
@@ -0,0 +1,38 @@
+#autoload
+
+# Complete files and expand tilde expansions in it.
+
+if [[ ( -o magicequalsubst && "$IPREFIX" = *\= ) || $argv[(I)-W*] -ne 0 ]]; then
+  _files "$@"
+  return
+fi
+
+case "$PREFIX" in
+\~/*)
+  IPREFIX="${IPREFIX}${HOME}/"
+  PREFIX="${PREFIX[3,-1]}"
+  _files "$@" -W "${HOME}"
+  ;;
+\~*/*)
+  local user="${PREFIX[2,-1]%%/*}"
+
+  if (( $+userdirs[$user] )); then
+    user="$userdirs[$user]"
+  elif (( $+nameddirs[$user] )); then
+    user="$nameddirs[$user]"
+  else
+    _message "unknown user \`$user'"
+    return 1
+  fi
+  IPREFIX="${IPREFIX}${user%/}/"
+  PREFIX="${PREFIX#*/}"
+  _files "$@" -W "$user"
+  ;;
+\~*)
+  compset -P '?'
+  _users "$@"
+  ;;
+*)
+  _files "$@"
+  ;;
+esac