[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 17 May 2013 14:50:09 -0700 (PDT)
I need some help and possibly also an advice.
Is it possible to retrieve the COMPREPLY variable outside and/or after calling
the complete function?
I'm working a special terminal emulator inherited from gnome-terminal. I want
to modify the common TAB behaviour and manipulate the result of all
TAB-completions: any string generated from the complete builtin function (and
also any other bash-completion extension) should go handled by me.
Ex: if in the terminal a TAB is pressed after a "ls /" I want to get all the
"bin/ initrd.img mnt/ selinux/ vmlinuz ...". Also I want the "add commit init
repack ..." given after a "git "+TAB.
My idea was to call something like a getenv("COMPREPLY") from whitin my
terminal emulator, read the result and then decide what&if to display to the
But in the source I can see this (pcomplete.c):
/* XXX - should we unbind COMPREPLY here? */
Ehm! So there is no way...?
Also I would need to know if in the COMPREPLY there are filenames or not.
I could trap any user TAB press and treat all the following strings from the
pty as result of a completion (until I get the prompt again)... but then I
should at least know if a program is running or not: maybe the user is just
pressing tab inside vim.
I do not know how to do that, and anyway it sounds like a bad hack...
Also I cannot modify any part of the the existing system: my terminal will run
mostly remotely connected over ssh. Of course I could run some bash script at
login, but I have to keep it simple.
Another idea is to add a delimitation around the completion result: I could
trap it easily. But I did not find how do that.
Last idea: trap the TAB from the user input and call directly the complete()
readline function, putting the result somewhere in the env (or directly in my
In the end it seems readline already has everything I need: I simply do not
know how to access its info.
I'm not actually sure if this is the right place for this question...
Any helps or suggestion will be appreciated.
- COMPREPLY scope,
Mario Signorino <=