zsh-workers
 help / color / mirror / code / Atom feed
6c52bc1f4a0c4a042b8c3cc099cadb1987fa5d41 blob 1424 bytes (raw)

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
#autoload

# Helper function for _path_files to handle the file-list style.

# arguments:
#  name of parameter containing file matches
#  directory prefix
# Sets array listfiles to the display strings and the array
# listopts appropriately to be added to the compadd command line.

local stat f elt what dir
local -a stylevals
integer ok

listfiles=()
listopts=()

zstyle -a ":completion:${curcontext}:" file-list stylevals || return 1

# TODO: more flexible way of handling the following?  e.g. use $compstate?
case $WIDGETSTYLE in
  (*complete*)
  what=insert
  ;;

  (*)
  what=list
  ;;
esac

for elt in $stylevals; do
  case $elt in
    (*($what|all|true|1|yes)*=<->)
    # use long format if no more than the given number of matches
    (( ${(P)#1} <= ${elt##*=} )) && (( ok = 1 ))
    break
    ;;

    ([^=]#($what|all|true|1|yes)[^=]#)
    # always use long format
    (( ok = 1 ))
    break
    ;;
  esac
done

(( ok )) || return 1

zmodload -F zsh/stat b:zstat 2>/dev/null || return 1

dir=${2:+$2/}
dir=${(Q)dir}

for f in ${(PQ)1}; do
  if [[ ! -e "$dir$f" ]]; then
    listfiles+=("$dir$f")
    continue
  fi

  # Borrowed from Functions/Example/zls
  zstat -s -H stat -F "%b %e %H:%M" - "$dir$f" >/dev/null 2>&1

  listfiles+=("$stat[mode] ${(l:3:)stat[nlink]} ${(r:8:)stat[uid]} \
 ${(r:8:)stat[gid]} ${(l:8:)stat[size]} $stat[mtime] $f")
done

(( ${#listfiles} )) && listopts=(-d listfiles -l -o)

return 0
debug log:

solving 6c52bc1f4 ...
found 6c52bc1f4 in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).