summary refs log tree commit diff
path: root/Completion/X/Utility/_x_arguments
blob: 6bda630763db1573a4a5dca42f2887b2ff744004 (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*|[CRWsw]) ]]; 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