summaryrefslogtreecommitdiff
path: root/Completion/User/_gdb
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_gdb')
-rw-r--r--Completion/User/_gdb52
1 files changed, 28 insertions, 24 deletions
diff --git a/Completion/User/_gdb b/Completion/User/_gdb
index ff54e6a07..55e149bb7 100644
--- a/Completion/User/_gdb
+++ b/Completion/User/_gdb
@@ -1,36 +1,44 @@
#compdef gdb
-# This uses the configuration keys `ps_args' and `ps_listargs'
-# described in the `_wait' function.
+local cur="$words[CURRENT]" prev w list ret=1 expl
-local cur="$words[CURRENT]" prev w list ret=1
-
-_long_options -t '*=(CORE|SYM)FILE' '_files' \
- '*=EXECFILE' '_files *(*)' \
- '*=TTY' 'compadd /dev/tty*' && return 0
+[[ "$PREFIX" = --* ]] &&
+ _arguments -- '*=(CORE|SYM)FILE:core file:_files' \
+ '*=EXECFILE:executable:_files \*\(-\*\)' \
+ '*=TTY:terminal device:compadd /dev/tty\*' && return 0
if compset -P '-(cd|directory)='; then
_files -/
elif compset -P '-tty='; then
- compadd - /dev/tty*
+ _wanted devices expl 'terminal device' compadd - /dev/tty*
elif compset -P '-(exec|se)='; then
- _files -/g '*(*)'
+ _description files expl executable
+ _files "$expl[@]" -g '*(-*)'
elif compset -P '-(symbols|core|command)='; then
_files
-elif compset -P -; then
- compadd -QS '' - symbols\= exec\= se\= core\= command\= directory\= \
- cd\= tty\=
- compadd - help h s e c x d nx n quiet q batch fullname f b
+elif [[ "$PREFIX" = -* ]]; then
+ if _wanted options; then
+ 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
+ (( ret )) || return 0
+ done
+ fi
else
prev="$words[CURRENT-1]"
case "$prev" in
- (-d) _files -/ && return 0 ;;
- (-e) _files -/g '*(*)' && return 0 ;;
+ (-d) _files -/ && return 0 ;;
(-[csx]) _files && return 0 ;;
- (-b) compadd -V baud 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
- 9600 19200 38400 57600 115200 230400 && return 0 ;;
+ (-e) _description files expl executable
+ _files "$expl[@]" -g '*(-*)' && return 0 ;;
+ (-b) _wanted -V values expl 'baud rate' \
+ compadd 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
+ 9600 19200 38400 57600 115200 230400 && return 0 ;;
esac
+
w=( "${(@)words[2,-1]}" )
while [[ "$w[1]" = -* ]]; do
[[ "$w[1]" = -[decsxb] ]] && shift 1 w
@@ -38,13 +46,9 @@ else
done
if [[ $#w -gt 1 ]]; then
- _files && ret=0
- list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}}}
-")
- compadd -y list - ${${${(M)${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
-
- return ret
+ _alternative 'files:: _files' "processes:: _pids -m ${w[1]:t}"
else
- _files -/g '*(*)'
+ _description files expl executable
+ _files "$expl[@]" -g '*(-*)'
fi
fi