mirror of
https://github.com/zsh-users/zsh
synced 2024-11-02 20:47:49 +00:00
35234: better zfget completion with paths
This commit is contained in:
parent
63dfc82bd2
commit
fea56dc32b
2 changed files with 22 additions and 5 deletions
|
@ -1,5 +1,8 @@
|
|||
2015-05-30 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* Han Pingtian: 35324: Functions/Zftp/zfget_match: better zfget
|
||||
completion with paths.
|
||||
|
||||
* Han Pingtian: 35311: Doc/Zsh/zftpsys.yo: typo in zfuput
|
||||
behaviour.
|
||||
|
||||
|
|
|
@ -9,17 +9,31 @@ if [[ $1 == $HOME || $1 == $HOME/* ]]; then
|
|||
fi
|
||||
|
||||
if [[ $ZFTP_SYSTEM == UNIX* && $1 == */* ]]; then
|
||||
setopt localoptions clobber
|
||||
setopt localoptions clobber extendedglob
|
||||
local tmpf=${TMPPREFIX}zfgm$$
|
||||
zf_ln -fn =(<<<'') $tmpf || return 1
|
||||
|
||||
if [[ -n $WIDGET ]]; then
|
||||
local dir=${1:h}
|
||||
local dir=${1%/*}
|
||||
[[ $dir = */ ]] || dir="$dir/"
|
||||
zftp ls -LF $dir >$tmpf
|
||||
local reply
|
||||
reply=(${${${(f)"$(<$tmpf)"}##$dir}%\*})
|
||||
_wanted files expl 'remote file' compadd -P $dir - $reply
|
||||
local reply1 reply2
|
||||
|
||||
# dirs in reply1, files in reply2
|
||||
reply1=(${${(M)${${(f)"$(<$tmpf)"}##$dir}:#*/}%/})
|
||||
reply2=(${${${${(f)"$(<$tmpf)"}##$dir}%\*}:#*/})
|
||||
|
||||
# try dir if ls -F doesn't work
|
||||
if ! (($#reply1)); then
|
||||
zftp dir $dir >$tmpf
|
||||
reply1=(${(M)${(f)"$(<$tmpf)"}:#d([^[:space:]]##[[:space:]]##)(#c8)?##})
|
||||
reply1=(${reply1/(#b)d([^[:space:]]##[[:space:]]##)(#c8)([^\/]##)\/#/$match[2]})
|
||||
|
||||
reply2=(${${(f)"$(<$tmpf)"}:#d([^[:space:]]##[[:space:]]##)(#c8)?##})
|
||||
reply2=(${reply2/(#b)([^[:space:]]##[[:space:]]##)(#c8)(?##)/$match[2]})
|
||||
fi
|
||||
_wanted directories expl 'remote directory' compadd -S/ -q -P $dir - $reply1
|
||||
_wanted files expl 'remote file' compadd -P $dir - $reply2
|
||||
else
|
||||
# On the first argument to ls, we usually get away with a glob.
|
||||
zftp ls "$1*$2" >$tmpf
|
||||
|
|
Loading…
Reference in a new issue