-
Notifications
You must be signed in to change notification settings - Fork 15
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 for python based commands (Ansible) #31
Comments
Just a quick update, meanwhile I figured out, how to solve the problem manually: $global:WslCompletionFunctions["ansible-playbook"] = '_python_argcomplete_global "ansible-playbook"' When I execute this, the tab completion works as expected in PowerShell. Of course it would be nice, if the module could figure this out by itself, but as said my knowledge about bash is very low. Maybe this helps |
Thanks for filing. I'll take a look. |
I don't seem to get completions within WSL. I tried with both WSL 1 and WSL 2. I installed ansible and python3-argcomplete. Am I missing something else? |
You are almost there. You need ansible and python3-argcomplete. Then you need to run:
|
Thanks. I see what's happening here. I'll need to think through how to potentially handle this. |
Could you try out the latest changes in the master branch? Just overwrite your copy of You'll need to clear your WslCompletionFunctions cache by running |
I did a small test and it looks good. A little bit strange to see "-D" in the output of the completion functions, but it works. Personally I would have used a specific variable like WslCompletionLoader, but from a user perspective it works. (Speaking of variables, maybe it is a good idea to initialize the WslDefaultParameterValues as an emtpy hashtable, if it does not already exist while loading the module. I find it always annoying to check if it exists before I can add a value. It has nothing to do with this topic,.) |
Excellent.
I wanted to keep the global session state clean unless you use a feature, and I'd expect if you're reusing your preferred defaults, you would initialize the hash table in your profile. |
Describe the bug
The argument completer does not find the correct completion for python based commands.
To Reproduce
Steps to reproduce the behavior:
apt install ansible
apt install python3-argcomplete
Test functionality in wsl, e.g.
ansible-playbook --a
this results in
ansible-playbook --ask
Leave wsl and create the command in PowerShell:
Import-WslCommand ansible-playbook
Expected behavior
Getting the same result in PowerShell, but
ansible-playbook --a
results in
ansible-playbook --a
So nothing happens.
Additional context
The behavior is clear, if I query the following in PowerShell
$global:WslCompletionFunctions
I can see that the value for ansible-playbook is "_minimal".
So basically the problem is in line 126 of WslInterop.psm1:
$global:WslCompletionFunctions[$command] = wsl.exe bash -c ". /usr/share/bash-completion/bash_completion 2> /dev/null; __load_completion $command 2> /dev/null; complete -p $command 2> /dev/null | sed -E 's/^complete.-F ([^ ]+).`$/\1/'"
My bash knowledge is way too low to fix this.
Do you have any idea how to fix this or at least what I can manually set by:
$global:WslCompletionFunctions["ansible-playbook"] = "???"
Thx for your great module, I enjoy it almost every day, but this would improve my work even a little more.
The text was updated successfully, but these errors were encountered: