Bash autocomplete for qdbus

John Tapsell johnflux at gmail.com
Sun Oct 14 12:35:40 BST 2007


  Ah thanks Thiago!  That now fixes the problem.  An updated version below.

  Is there a standard place to install a file with this function in
it, so that it can be installed nicely by a package?

#!/bin/bash
function _qdbus ()
{
    COMPREPLY=()

    #Get the currently typed word
    cur="${COMP_WORDS[COMP_CWORD]}"

    #Get the rest of the words
    unset COMP_WORDS[COMP_CWORD]

    if [[ ${#COMP_WORDS[*]} -lt 4 ]] ; then
        #Run qdbus and get a list of all the possibilities, filtering
out everything but the actual method name (arguments etc)
        options='$(${COMP_WORDS[*]} |  sed -e "s/^.* \([^ ]*\)([^()]*)$/\1/")'

        #Set the autocomplete replies, filtering for matches for the
currently typed word
        COMPREPLY=( $(compgen -W "${options}" -- ${cur}) )
    fi
}

complete -F _qdbus qdbus




More information about the kde-core-devel mailing list