I successfully completed bash for my user commands when the parameters did not contain special characters in them using the compression mechanism:
current=${COMP_WORDS[COMP_CWORD]} all=$(_get_all_items) COMPREPLY=( $(compgen -W "$all" -- $current) ) ... complete -F _prog_compl prog
I use the same approach to populate elements that start with a colon :first :second , ... But it does not show me / auto-complete them. I tried to break out of the colon with a backslash, which didn't work either. How can I hide colons at the end?
Elements begin with a colon, let them say :first :second . If I write progname and start with a colon, like this:
$ progname :<Tab here after colon>
I see without completion , but two colons ("::") - one of them is automatically added to line I. If I convert the colon to a regular character (say, "b"), I get the completion exactly the way I want: bfirst , bsecond ...
It is important to note that when I click the tab, it places another ":" next to my previously inserted colon and becomes "::".
$ bash --version GNU bash, version 4.1.10(2)-release (i486-slackware-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
In addition, I have done several experiments in the shell that give:
$ compgen -W ":aaaa5 :gb2 :cd3" -- ":" :aaaa5 :gb2 :cd3
Nevertheless, it strangely puts another ":" on my only ":" and makes it "::" after entering: on the command line.
$ complete complete -F _alp_compl alp.sh complete -o nospace -F __dbus_send dbus-send complete -F _myprog_compl myprog complete -o nospace -F __gdbus gdbus complete -o nospace -F __gsettings gsettings