about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-25 09:53:18 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-25 09:53:18 +0000
commit39b2b5eb2a3a1889e78eb2b3f101f2c529c5bf03 (patch)
treea81c50993f5d3a288524f30e45abca7ecf60fec1 /Completion
parent6785dcb5c920b6be812b4d1a70ce53ed47ff2f30 (diff)
downloadzsh-39b2b5eb2a3a1889e78eb2b3f101f2c529c5bf03.tar.gz
zsh-39b2b5eb2a3a1889e78eb2b3f101f2c529c5bf03.tar.xz
zsh-39b2b5eb2a3a1889e78eb2b3f101f2c529c5bf03.zip
zsh-workers/9870
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_path_files2
-rw-r--r--Completion/User/.distfiles4
-rw-r--r--Completion/User/_dd4
-rw-r--r--Completion/User/_tilde_files38
4 files changed, 43 insertions, 5 deletions
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 892450f53..60a266482 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -36,7 +36,7 @@ if (( $#prepaths )); then
   if [[ "$tmp1[1]" = '(' ]]; then
     prepaths=( ${^=tmp1[2,-2]%/}/ )
   elif [[ "$tmp1[1]" = '/' ]]; then
-    prepaths=( "$tmp1/" )
+    prepaths=( "${tmp1%/}/" )
   else
     prepaths=( ${(P)^tmp1%/}/ )
     (( ! $#prepaths )) && prepaths=( ${tmp1%/}/ )
diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles
index 4550b9c4d..7dafbfbca 100644
--- a/Completion/User/.distfiles
+++ b/Completion/User/.distfiles
@@ -9,7 +9,7 @@ DISTFILES_SRC='
     _perl_basepods _perl_builtin_funcs _perl_modules _perldoc
     _ports _prcs _prompt _ps _pspdf _psutils _rcs _rlogin _sh _socket
     _ssh _strip _stty _su _sudo _tar _tar_archive _telnet _tex _texi
-    _tiff _uncompress _unpack _urls _use_lo _user_at_host _users
-    _users_on _webbrowser _wget _whereis _whois _xargs _yodl _yp
+    _tiff _tilde_files _uncompress _unpack _urls _use_lo _user_at_host
+    _users _users_on _webbrowser _wget _whereis _whois _xargs _yodl _yp
     _zdump
 '
diff --git a/Completion/User/_dd b/Completion/User/_dd
index 3ae0a8417..fa322d791 100644
--- a/Completion/User/_dd
+++ b/Completion/User/_dd
@@ -11,10 +11,10 @@ if compset -P 1 'conv='; then
               ascii ebcdic ibm block unblock lcase ucase swab noerror sync
 elif compset -P 1 'if='; then
   _description files expl 'input file'
-  _files "$expl[@]"
+  _tilde_files "$expl[@]"
 elif compset -P 1 'of='; then
   _description files expl 'output file'
-  _files "$expl[@]"
+  _tilde_files "$expl[@]"
 else
   _wanted values expl option &&
       compadd "$expl[@]" -S '=' if of ibs obs bs cbs skip files seek count conv
diff --git a/Completion/User/_tilde_files b/Completion/User/_tilde_files
new file mode 100644
index 000000000..6fb393dc5
--- /dev/null
+++ b/Completion/User/_tilde_files
@@ -0,0 +1,38 @@
+#autoload
+
+# Complete files and expand tilde expansions in it.
+
+if (( $argv[(I)-W*] )); 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