79f4cb4b426ca798e6ee70be1344919dab633ca9
[platform/upstream/glib.git] / gio / gdbus-bash-completion.sh
1
2 # Check for bash
3 [ -z "$BASH_VERSION" ] && return
4
5 ####################################################################################################
6
7
8 __gdbus() {
9     local IFS=$'\n'
10     local cur=`_get_cword :`
11
12     local suggestions=$(gdbus complete "${COMP_LINE}" ${COMP_POINT})
13     COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
14
15     # Remove colon-word prefix from COMPREPLY items
16     case "$cur" in
17         *:*)
18             case "$COMP_WORDBREAKS" in
19                 *:*)
20                     local colon_word=${cur%${cur##*:}}
21                     local i=${#COMPREPLY[*]}
22                     while [ $((--i)) -ge 0 ]; do
23                         COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
24                     done
25                     ;;
26             esac
27             ;;
28     esac
29 }
30
31 ####################################################################################################
32
33 complete -o nospace -F __gdbus gdbus