about summary refs log tree commit diff
path: root/Completion/Core/_files
blob: 4adae0f736d2cadf6453334dfe5c0b3b6d35a199 (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
#autoload

local opts opt type=file tags

opts=()
while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:" opt; do
  case "$opt" in
  /)    [[ "$type" = file       ]] && type=dir       ;;
  g)    [[ "$type" = (file|dir) ]] && type="$OPTARG" ;;
  q)    opts=("$opts[@]" -q               )          ;;
  [^f]) opts=("$opts[@]" "-$opt" "$OPTARG")          ;;
  esac
done

case "$type" in
file) _tags -f "$funcstack[2]" file           ;;
dir)  _tags -f "$funcstack[2]" path file      ;;
*)    _tags -f "$funcstack[2]" glob path file ;;
esac

while _tags; do
  [[ "$tags" = *:file:* ]] && { _path_files "$opts[@]" -f         ;  return   }
  [[ "$tags" = *:path:* ]] &&   _path_files "$opts[@]" -/         && return 0
  [[ "$tags" = *:glob:* ]] &&   _path_files "$opts[@]" -g "$type" && return 0
done

return 1