Comments for bash programmable completion

11 Jul 2005 17:39 ianmacd

Re: Variable-name completion bug


> When I tab out an environment variable

> during a cd, the $(dollar sign) sign is

> escaped so although the tab completion

> happens the cd doesn't work. e.g

>

> cd $JA[hit tab] and this lines becomes

> cd \$JAVA_HOME[hit enter] and I get

> -bash: cd: $JAVA_HOME: No such file or

> directory

>

> If I comment out the bash-completion

> line in .bashrc this doesn't happen -

> the tab completion works correctly.

>

> I'm using

> bash-2.05b-r9

> bash-completion 20040526

>

> I started this thread on the gentoo

> forums

> http://forums.gentoo.org/viewtopic.php?p=1419973#1419973

>

> and mhodak has tried the latest version

> available 20040704-r1, and reports the

> bug is still there.

To get the behaviour you desire. you have to change this line:

complete -v -F _cd $nospace $filenames cd

Remove '$filenames', which will cause bash to no longer treat the

variable name as a filename, so it won't escape it.

Unfortunately, it will now also no longer append a slash to a path.

These are the kinds of trade-offs that bash's programmable completion

implementation requires, I'm afraid.

11 Jul 2005 17:34 ianmacd

Re: Subversion completion


> There is a completion script at

> http://worksintheory.org/files/misc/bash_completion_svn

> which is much better than the one

> currently shipped with contrib. May be

> that could be included in the next

> release.

Who is the copyright holder of this file? I can't start to package it without his agreement, as the file itself contains no licensing information.

11 Jul 2005 17:28 ianmacd

Re: Thanks but please remove The Feature


>

> % % Please Sir: stop ending EVERY subdir

> with a space.

> % %

> % % If it can't be done then I must

> % % uninstall. :(

> %

> % The limitation you describe is not

> % something that the bash completion

> does;

> % it's a limiation of bash, itself.

>

> Ian, Please let me say that I can only

> think of two words to your reply and I

> mean them tongue in cheek: "prove it!"

> :)

>

> LOL.

>

> What I mean is (I haven't studied the

> code yet) I think $IFS is being used an

> extra time. Hope this helps.

Please tell me which particular command is giving you this behaviour and which version of bash you are using.

07 Jul 2005 17:13 ianmacd

Re: BASH_COMPLETION is readonly, except in functions?


> At the top of the script, whether or not

> it is being sourced

> inside a function is checked. If so,

> then set the variables. If

> not, then set them to be read-only.

>

> Obviously, the better behaviour would be

> to make them

> readonly all the time, but this is not

> implemented because

> `declare -r' would then make those

> variables local to the

> function. Here is a fix:

>

> Use the `readonly' builtin. In fact,

> using this can mean that

> the check for "$FUNCNAME" can

> be removed completely.

> Simply:

>

> BASH_COMPLETION=blah

> readonly BASH_COMPLETION

>

> All done. :-)

>

> Unless I've missed something, this would

> be a welcome

> change in the next release. (I do source

> bash_completion

> from a function.)

>

> JP

Unfortunately, this causes an error to be printed if 'BASH_COMPLETION=blah' is executed for a second time. Redirection doesn't work on assignment, so this can't be silenced, except by using 'declare', which makes the variable local to the function.

25 Apr 2005 15:25 gaelicWizard

BASH_COMPLETION is readonly, except in functions?
At the top of the script, whether or not it is being sourced

inside a function is checked. If so, then set the variables. If

not, then set them to be read-only.

Obviously, the better behaviour would be to make them

readonly all the time, but this is not implemented because

`declare -r' would then make those variables local to the

function. Here is a fix:

Use the `readonly' builtin. In fact, using this can mean that

the check for "$FUNCNAME" can be removed completely.

Simply:

BASH_COMPLETION=blah

readonly BASH_COMPLETION

All done. :-)

Unless I've missed something, this would be a welcome

change in the next release. (I do source bash_completion

from a function.)

JP

28 Mar 2005 20:21 andyetitmoves

Subversion completion
There is a completion script at http://worksintheory.org/files/misc/bash_completion_svn which is much better than the one currently shipped with contrib. May be that could be included in the next release.

11 Mar 2005 09:49 jamespo

autocompletion of mutt aliases?
great project - there is one feature I'd like

the ability to autocomplete based on mutt's ~/.mutt.aliases file.

ie mutt [tab][tab]

gives a list of mutt aliases for recipients

I have tried to code this, but failed,

22 Oct 2004 03:03 virginiogl

Suggestion
I think that implement bash completion for emerge

utility of Gentoo distibution is a good idea.

Emerge is similar to apt-get in Debian.

Thanks.

09 Oct 2004 01:13 Gouri48

Thank you (Re: Please allow user to revert to standard bash completion at any time (a must-have).)

> Yes, just run 'complete -r' and all

> completions will be removed, leaving

> just the default. However, I agree that

> this isn't the most useful way of

> achieving this, so I will consider the

> implementation of a better mechanism.

Thank you. A quick test showed that

indeed the "broken" behaviors do work again. This is
enough for my purpose and some

investigation will allow to selectively remove some of the

completions but not all.


Thank you for this constructive reply.

May I suggest to include both explanations (about the need

that the env variables do not change, and a way to turn the

feature off -- although the latter is actually a bash feature) in

the package documentation and on the project web page ?

Regards,

08 Oct 2004 17:20 ianmacd

Re: Please allow user to revert to standard bash completion at any time (a must-have).


> So, any user should be able to turn it

> off. The simplest

> idea is to unset the involved

> environment variables.

>

> But BASH_COMPLETION and

> BASH_COMPLETION_DIR

> are declared as read-only. Why ?

> This prevents a particular user to turn

> it off... :-(

These are set read-only, because it's bad to change them once they've been set. They are used later on and it's important that the value doesn't change. They can be set before the bash_completion script is run, however, and the original value will be honoured.

> On a system with many users, there's

> currently no other

> choice than to ask the administrator to

> remove the

> package for all users (or make it not

> activated by default,

> which is not what we need either).

>

> Is it currently possible for a user to

> revert to standard

> bash completion ?

Yes, just run 'complete -r' and all completions will be removed, leaving just the default. However, I agree that this isn't the most useful way of achieving this, so I will consider the implementation of a better mechanism.

> A last suggestion : use

> savannah.nongnu.org or

> sourceforge.net to have real forums.

> Freshmeat comments

> aren't structured enough so that

> contributors can make a

> good job of checking if a request was

> already issued

> before. User feedback quality depends on

> this.

Well, e-mail works well, too. I agree that this forum isn't very efficient or convenient, so just e-mail me your comments instead. It would be nice to have a real mailing list, though. I'll consider setting one up.

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.