Bash autocomplete for qdbus
John Tapsell
johnflux at gmail.com
Sun Oct 14 00:27:41 BST 2007
Hi,
I wrote a small autocomplete script for qdbus:
function _qdbus ()
{
COMPREPLY=()
#Get the currently typed word
cur="${COMP_WORDS[COMP_CWORD]}"
#Get the rest of the words
unset COMP_WORDS[COMP_CWORD]
#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}) )
}
complete -F _qdbus qdbus
Just stick it in .bashrc etc.
It works pretty well, but works by running qdbus each time, to get the
list of available functions. Unfortunately this means that on the
last autocomplete, it will actually run the method - so not that
great!
I don't think I can really solve this from the bash script, so maybe
we could persuade the trolls to add a parameter to qdbus to just
return a plain list of possible functions, with no risk of actually
executing the function?
Any suggestions?
John
More information about the kde-core-devel
mailing list