Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~/.bash_completion.d/python-argcomplete.sh prevents other completions #67

Closed
jmlopez-rod opened this issue Dec 27, 2013 · 6 comments · Fixed by #284
Closed

~/.bash_completion.d/python-argcomplete.sh prevents other completions #67

jmlopez-rod opened this issue Dec 27, 2013 · 6 comments · Fixed by #284

Comments

@jmlopez-rod
Copy link

I noticed a while ago that when I source the script python-argcomplete.sh I cannot tab to complete environment variables. If I comment the last line in the script:

#complete -o default -D -F _python_argcomplete_global

Then I can do:

macbook-pro:~ jmlopez$ echo $PA<TAB>
macbook-pro:~ jmlopez$ echo $PATH

As soon as I activate the global completer then it doesn't do the environment variable completion anymore. This behavior does not happen when registering an awesome script, i.e.

eval "$(register-python-argcomplete my-awesome-script.py)"

Not sure if this is happening with others, can someone check if this is bug on argparse? I'm using bash 4.2:

macbook-pro:~ jmlopez$ echo $BASH_VERSION
4.2.45(2)-release
@jmlopez-rod
Copy link
Author

I found some bash reference on complete and the -o option got my attention:

-o comp-option

The comp-option controls several aspects of the compspec’s behavior beyond the simple generation of completions. comp-option may be one of:

bashdefault
Perform the rest of the default Bash completions if the compspec generates no matches.
default
Use Readline’s default filename completion if the compspec generates no matches.

It seems that adding the bashdefault option fixes the problem:

complete -o default -o bashdefault -D -F _python_argcomplete_global

Now it completes the environment variables as well.

@kislyuk
Copy link
Owner

kislyuk commented Dec 27, 2013

Thank you for your contribution. I wasn't aware of the difference, and see no reason not to add -o bashdefault.

Released in v0.6.6, please give it a try.

@jmlopez-rod
Copy link
Author

Good to know, I hope this doesn't cause any other side effects. I have been testing it with my scripts and my regular use of bash and everything seems to work. Thank you.

@jiasli
Copy link
Contributor

jiasli commented Jan 3, 2020

register-python-argcomplete is not using -o bashdefault by default:

complete_options = '-o nospace -o default' if use_defaults else '-o nospace'

Although it can be overridden with --complete-arguments, maybe we can include -o bashdefault for individual command registration as well?

@evanunderscore
Copy link
Collaborator

Thank you for reporting @jiasli. This appears to be an oversight. Would you like to submit a PR?

@jiasli
Copy link
Contributor

jiasli commented Jan 10, 2020

Sure. With pleasure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants