shell - Bash Command-Line Tab Completion Colon Character -
i have implemented bash completions custom commands when parameters contained no special characters in them, compgen mechanism:
current=${comp_words[comp_cword]} all=$(_get_all_items) compreply=( $(compgen -w "$all" -- $current) ) ... complete -f _prog_compl prog
i use same approach complete items start colon character: :first
, :second
, ... fails show me / autocomplete them. tried escaping colons backslashes didn't work either. how should escape colons in completion?
the items starting colon, let's say: :first
, :second
. if write progname , start colon this:
$ progname :<tab here after colon>
i see no completion 2 colons ("::") - 1 of them automatically added line type. if convert colon ordinary character (let's 'b') completion want: bfirst
, bsecond
...
it relevant note when press tab places ":" next inserted colon , 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> free software; free change , redistribute it. there no warranty, extent permitted law.
additionally, have made experiments in shell yield:
$ compgen -w ":aaaa5 :gb2 :cd3" -- ":" :aaaa5 :gb2 :cd3
yet strangely puts ":" sole ":" , makes "::" after type : on 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
after consulting help-bash@gnu.org got answer:
the colon breaks words completion system (look @ description of comp_wordbreaks shell variable), when type
progname :[tab]
the completion system gets empty word complete. if of possible completions have `:' longest common prefix, completion system insert colon line.
and comp_wordbreaks search yield me answer stackoverflow.
after fixing (my missing) /etc/bash_completion file debian bash completion page, now, colon-initiated completion working will.
Comments
Post a Comment