You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi all
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 user.
But in the source I can see this (pcomplete.c):
/* XXX - should we unbind COMPREPLY here? */
unbind_variable ("COMPREPLY");
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 code). How?
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.
Tnx
Mario
Chet Ramey
unread,
May 22, 2013, 10:25:16 AM5/22/13
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mario Signorino, bug-...@gnu.org, chet....@case.edu
On 5/17/13 5:50 PM, Mario Signorino wrote:
> Hi all
>
> 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?
No. The programmable completion code unsets COMPREPLY after the shell
function completes. You might have some luck experimenting with the
default completion feature (complete -D), but you'll have to do all the
dispatching yourself.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bug-...@gnu.org
On Fri, May 17, 2013 at 02:50:09PM -0700, Mario Signorino wrote:
> Another idea is to add a delimitation around the completion result: I
> could trap it easily. But I did not find how do that.
I thought about time some times ago.
My goal was to enclose the burn-cd files completion result with a
text-based gauge showing the amount of files according to the media
size limit.
For this to work I needed some new hooks inside the bash completion
system.
You may also give a look at an attempt to add per-completion settings in
the above-mentioned bash repository at e9b65ae and a123ad7
(that was about a per-completion "wordbreaks" setting)