summaryrefslogtreecommitdiff
path: root/completions/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'completions/gdb')
-rw-r--r--completions/gdb31
1 files changed, 12 insertions, 19 deletions
diff --git a/completions/gdb b/completions/gdb
index f0bc42d3..c24407b5 100644
--- a/completions/gdb
+++ b/completions/gdb
@@ -1,16 +1,13 @@
-# bash completion for gdb
+# bash completion for gdb -*- shell-script -*-
-have gdb &&
_gdb()
{
- local cur prev
+ local cur prev words cword
+ _init_completion || return
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
-
- if [ $COMP_CWORD -eq 1 ]; then
+ if [ $cword -eq 1 ]; then
local IFS
- _compopt_o_filenames
+ compopt -o filenames
if [[ "$cur" == */* ]]; then
# compgen -c works as expected if $cur contains any slashes.
IFS=$'\n'
@@ -27,18 +24,14 @@ _gdb()
-mindepth 1 -maxdepth 1 -not -type d -executable \
-printf "%f\\n" 2>/dev/null)' -- "$cur" ) )
fi
- elif [ $COMP_CWORD -eq 2 ]; then
- prev=${prev##*/}
- COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
- awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" -- "$cur" ) )
+ elif [ $cword -eq 2 ]; then
+ COMPREPLY=( $( compgen -W "$( command ps axo comm,pid | \
+ awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}' )" -- "$cur" ) )
+ compopt -o filenames
+ COMPREPLY+=( $( compgen -f -X '!?(*/)core?(.+([0-9]))' -o plusdirs \
+ -- "$cur" ) )
fi
} &&
-complete -F _gdb -o default gdb
+complete -F _gdb gdb
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh