about summary refs log tree commit diff
path: root/Functions/Zftp/zfget_match
blob: 1d90bea60155a6d8c30172b421d812f3155dc7d7 (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
# 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
    _wanted files expl 'remote file' compadd -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
    _wanted files expl 'remote file' compadd -F fignore - ${(P)fcache_name}
  else
    reply=(${(P)fcache_name});
  fi
fi
# }