about summary refs log tree commit diff
path: root/Functions/Zftp/zfget_match
blob: cd34c095ce46eea08bf543e4174b7515a3ec3c09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# function zfget_match {

emulate -L zsh

# the zfcd hack:  this may not be necessary here
if [[ $1 == $HOME || $1 == $HOME/* ]]; then
  1="~${1#$HOME}"
fi

local tmpf=${TMPPREFIX}zfgm$$

if [[ $ZFTP_SYSTEM == UNIX* && $1 == */* ]]; then
  if [[ -n $WIDGET ]]; then
    local dir=${1:h}
    [[ $dir = */ ]] || dir="$dir/"
    zftp ls -LF $dir >$tmpf
    local reply
    reply=(${${${(f)"$(<$tmpf)"}##$dir}%\*})
    rm -f $tmpf
    _description files expl 'remote file'
    compadd "$expl[@]" -P $dir - $reply
  else
    # On the first argument to ls, we usually get away with a glob.
    zftp ls "$1*$2" >$tmpf
    reply=($(<$tmpf))
    rm -f $tmpf
  fi
else
  local fcache_name
  zffcache
  if [[ -n $WIDGET ]]; then
    _description files expl 'remote file'
    compadd "$expl[@]" -F fignore - ${(P)fcache_name}
  else
    reply=(${(P)fcache_name});
  fi
fi
# }