From 39b2b5eb2a3a1889e78eb2b3f101f2c529c5bf03 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 25 Feb 2000 09:53:18 +0000 Subject: zsh-workers/9870 --- Completion/User/.distfiles | 4 ++-- Completion/User/_dd | 4 ++-- Completion/User/_tilde_files | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 Completion/User/_tilde_files (limited to 'Completion/User') 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 -- cgit 1.4.1