[Bash-completion-devel] about bash_completion_lib and completion/suggestion disassiociation

gibboris at gmail.com gibboris at gmail.com
Sun Mar 29 02:24:53 UTC 2009


Hi,
for sometimes now I'm looking for a way to disassociate to suggestions
of completion (where $IFS is used to print all possibilities) and
completion which come under the shell cursor (I didn't find other
semantics)

It would let solve :
- #311418 (DBTS 393338): tab completion should show dirs in blue and
executables in green
- print the summary of the options while completing with the option
alone
- ...

Sometimes ago I asked over the IRC about this feature after having dug
around _filedir().
But the only variable bash use seems to be $COMPREPLY which do BOTH,
even if compgen seems flexible enough with the -F option.
I was just said that it was *maybe* possible with the
bash_completion_lib.
So I'm asking if anybody went into this code (a bit harder for me) and
saw something like that. Also I wanted to know about the howto to
integrate bash-completion completions with lib_bash_completion (or the
opposite).

About bash4, if I understood the changelog, the new feature around the
completion is to let a function use different -o switch than the one
used for the whole completion, so, for example _filedir with -o nospace
and another one without nospace inside the same command completion,
right ?

Finally; I'm looking to move the source of bash_comp away from bashrc to
register the functions globally in the xinitrc (more precisely in my
bash_profile) to get it for my whole X and, after having exported the
functions, to make it work in any shell.
I understood that the completion is stored as full text
bash in RAM (so only the disk I/O are avoided) (and probably copied for
each new term instance to let it modify the completion locally if
needed) and I don't know about a way to share a static env over many
bash.
Anyway I tryed this :
typeset|grep '^_[^=]'|cut -d' ' -f1|while read f; do
       export -f "$f"
       echo "[export]$(date +%s):$f" >> /tmp/log_export
done
It *seems* that exporting a function with some special chars (like the
"case" statement needs) make export impossible.
Simple examples :
- export -f _autorpm ; xterm -> it works, _autorpm is exported.
- export -f _tar ; xterm -> it doesn't work :
bash: _tar: line 8: syntax error near unexpected token `('
bash: _tar: line 8: ` ?(-)[cr]*f)'
bash: error importing function definition for `_tar'

So... any comment, advices, openings appreciated :)

Raph



More information about the Bash-completion-devel mailing list