/usr/share/doc/bugz/contrib/bash-completion is in bugz 0.10.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #
# Bash completion support for bugz.
#
# Copyright 2012 Tim Stoakes <tim@stoakes.net>
#
# Complete a list of command names by scanning the help output.
__bugz_comp_commands_from_help ()
{
local cur="${3#$2}"
local opts
opts="$($1 --help | \
awk -F, '/^\s+\{/ {for(i=1; i<=NF; ++i) {sub(/\W+/, "", $i); print $i} exit;}')"
COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
}
# Complete a list of options, both generic, and specific to the given command,
# by scanning the help output.
__bugz_comp_opts_from_help ()
{
local cur="${3#$2}"
local opts
if [ "x" == "x$2" ]; then
opts="$($1 --help | \
awk '/^\s+-/ {for(i=1; i<=NF; ++i) if ($i~/^-.+$/) {sub(/,$/, "", $i); print $i}}')"
COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
else
opts="$($1 $2 --help 2>/dev/null | \
awk '/^\s+-/ {for(i=1; i<=NF; ++i) if ($i~/^-.+$/) {sub(/,$/, "", $i); print $i}}')"
if [ $? -eq 0 ]; then
COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
fi
fi
}
_bugz() {
local i c=1 command cur command_valid=0 bugz
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
bugz="${COMP_WORDS[0]}"
# Find the command name.
while [ $c -le $COMP_CWORD ]; do
i="${COMP_WORDS[c]}"
case "$i" in
-*) ;;
*)
# This is the best guess so far.
command="$i"
# Is it a valid command already?
$bugz $i --help > /dev/null 2>&1
if [ $? -eq 0 ]; then
# Yes! Stop looking.
command_valid=1
break 2
fi
;;
esac
c=$((++c))
done
case "$cur" in
-*)
# Complete an option.
__bugz_comp_opts_from_help "$bugz" "$command" "$cur"
return 0
;;
*)
if [ $command_valid -ne 1 ]; then
# Complete the command name if required.
__bugz_comp_commands_from_help "$bugz" "" $command
fi
# If there's anything left, don't complete it.
return 0
;;
esac
}
complete -F _bugz bugz
|