2
# Apport bash-completion
4
###############################################################################
6
# get available symptoms
10
for FILE in $(ls /usr/share/apport/symptoms); do
11
syms="$syms ${FILE%.py}"
17
# completion when used without parameters
18
_apport_parameterless ()
21
# parameter-less completion
22
# param= COMMAND parameters
26
# .crash/.apport files
28
$( apt-cache pkgnames $cur 2> /dev/null ) \
29
$( command ps axo pid | sed 1d ) \
30
$( _apport_symptoms ) \
31
$( compgen -G "${cur}*.apport"
32
compgen -G "${cur}*.crash" )"
33
COMPREPLY=( $( compgen -W "$param" -- $cur) )
37
# apport-bug ubuntu-bug completion
40
local cur dashoptions prev param
44
prev=${COMP_WORDS[COMP_CWORD-1]}
48
dashoptions='-h --help -f --file-bug -u --update-bug -s --symptom -p \
49
--package -P --pid -c --crash-file --save -v --version'
52
ubuntu-bug | apport-bug)
55
# parameter completion
56
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
68
param="-P --pid -p --package -s --symptom"
69
COMPREPLY=( $( compgen -W "$param $(_apport_symptoms)" -- $cur) )
73
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
78
COMPREPLY=( $( compgen -W "$param" -- $cur) )
82
COMPREPLY=( $( compgen -W "$(_apport_symptoms)" -- $cur) )
86
COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
90
COMPREPLY=( $( compgen -o default -G "$cur*" ) )
94
# only show *.apport *.crash files
95
COMPREPLY=( $( compgen -G "${cur}*.apport"
96
compgen -G "${cur}*.crash" ) )
99
-h | --help | -v | --version)
100
# standalone parameters
105
if [ "${COMP_WORDS[COMP_CWORD-2]}" == "--save" ]; then
106
# use same completion as if no parameter is given
109
# parameter completion
110
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
114
_apport_parameterless
120
# save is allowed for most parameters
122
COMPREPLY=( $( compgen -W "$param" -- $cur) )
130
# apport-cli completion
133
local cur dashoptions prev param
137
prev=${COMP_WORDS[COMP_CWORD-1]}
141
dashoptions='-h --help -f --file-bug -u --update-bug -s --symptom \
142
-c --crash-file --save -v --version'
148
# parameter completion
149
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
154
_apport_parameterless
161
param="-P --pid -p --package -s --symptom"
162
COMPREPLY=( $( compgen -W "$param $(_apport_symptoms)" -- $cur) )
166
COMPREPLY=( $( compgen -W "$(_apport_symptoms)" -- $cur) )
170
COMPREPLY=( $( compgen -o default -G "$cur*" ) )
174
# only show *.apport *.crash files
175
COMPREPLY=( $( compgen -G "${cur}*.apport"
176
compgen -G "${cur}*.crash" ) )
179
-h | --help | -v | --version)
180
# standalone parameters
185
if [ "${COMP_WORDS[COMP_CWORD-2]}" == "--save" ]; then
186
# use same completion as if no parameter is given
189
# parameter completion
190
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
194
_apport_parameterless
200
# save is allowed for most parameters
202
COMPREPLY=( $( compgen -W "$param" -- $cur) )
210
# apport-unpack completion
217
prev=${COMP_WORDS[COMP_CWORD-1]}
221
# only show *.apport *.crash files
222
COMPREPLY=( $( compgen -G "${cur}*.apport"
223
compgen -G "${cur}*.crash" ) )
229
# apport-collect completion
236
prev=${COMP_WORDS[COMP_CWORD-1]}
240
COMPREPLY=( $( compgen -W "-p --package" -- $cur) )
245
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
251
# bind completion to apport commands
252
complete -F _apport-bug -o filenames -o dirnames ubuntu-bug
253
complete -F _apport-bug -o filenames -o dirnames apport-bug
254
complete -F _apport-cli -o filenames -o dirnames apport-cli
255
complete -F _apport-unpack -o filenames -o dirnames apport-unpack
256
complete -F _apport-collect apport-collect