about summary refs log tree commit diff
path: root/Completion/X/Utility/_x_arguments
blob: 8f1723cc63590a6b71f6bbd263a9fb567bbe9419 (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
#compdef -P */X11(|R[456])/*

local ret long xargs opts rawret nm="$compstate[nmatches]"

xargs=(
  '-display:display:_x_display'
  '-geometry:geometry:_x_geometry'
)

(( $# )) || xargs=( "$xargs[@]" '*:default: _default' )

long=$argv[(I)--]
if (( long )); then
  argv[long]=( "$xargs[@]" -- )
else
  set -- "$@" "$xargs[@]"
fi

opts=()
while [[ $1 = -(O*|[CR]) ]]; do
  opts=($opts $1)
  [[ $1 = -R ]] && rawret=yes
  shift
done

_arguments -R "$opts[@]" "$@"

ret=$?

if [[ "$ret" = 300 ]]; then
  compstate[restore]=''
  [[ -z $rawret ]] && ret=$(( nm == $compstate[nmatches] ))
fi

return ret