about summary refs log tree commit diff
path: root/Completion/Unix/Command/_gdb
blob: 18f797633cba71de307001081b9155b7cff2313d (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#compdef gdb

local cur="$words[CURRENT]" prev w list ret=1 expl

[[ "$PREFIX" = --* ]] &&
    _arguments -- '*=(CORE|SYM)FILE:core file:_files' \
		  '*=EXECFILE:executable:_files -g \*\(-\*\)' \
		  '*=TTY: :_ttys -o' && return 0

if compset -P '-(cd|directory)='; then
  _files -/
elif compset -P '-tty='; then
  _ttys -o
elif compset -P '-(exec|se)='; then
  _description files expl executable
  _files "$expl[@]" -g '*(-*)'
elif compset -P '-(symbols|core|command)='; then
  _files
elif compset -P '--pid='; then
  _pids
elif [[ "$PREFIX" = -* ]]; then
  _tags options
  while _tags; do
    while _next_label options expl option; do
      compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \
                                  -directory\= -cd\= -tty\= && ret=0
      compadd "$expl[@]"        - -help -h -s -e -c -x -d -nx -n -quiet -q \
	    		          -batch -fullname -f -b && ret=0
    done
    (( ret )) || return 0
  done
else
  prev="$words[CURRENT-1]"

  case "$prev" in
  (-d)     _files -/ && return 0 ;;
  (-[csx]) _files && return 0 ;;
  (-e)     _description files expl executable
           _files "$expl[@]" -g '*(-*)' && return 0 ;;
  (-b)     _baudrates && return 0 ;;
  esac

  w=( "${(@)words[2,-1]}" )
  while [[ "$w[1]" = -* ]]; do
    [[ "$w[1]" = -[decsxb] ]] && shift 1 w
    shift 1 w
  done

  if [[ $#w -gt 1 ]]; then
    _alternative "files:: _files -g '*core*(-.)'" "processes:: _pids -m ${w[1]:t}"
  else
    _description files expl executable
    _files "$expl[@]" -g '*(-*)'
  fi
fi