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

Allow overwriting the type of tab complete in powershell with a environment variable to support alterative completion providers #2232

Open
Nova38 opened this issue Feb 10, 2025 · 2 comments

Comments

@Nova38
Copy link

Nova38 commented Feb 10, 2025

I initially made this issue under chezmoi, but was told I should make it in the upstream cobra repo instead.

twpayne/chezmoi#4251

Currently tab completion in PowerShell just looks up the what name of the function that is providing the completion. However, if a non standard function is used the completions default to the least detailed option. For example, if one was to use the PSFzf tab completion which uses fzf to display a preview of the different options like the 'MenuComplete' function then instead of seeing the description it won't show anything. Would it be possible to add a check to see if an environment variable has been set, something like chezmoi_completion_mode, and if so use that to determine the mode? Then in the event that it is not set default back to using the name of the function.

@marckhouzam
Copy link
Collaborator

IIUC, you would like a user to be able to set a cobra-specific variable (such as chezmoi_completion_mode) which would specify one of TabCompleteNext, Complete or MenuComplete and would take precedence over the call to Get-PSReadLineKeyHandler?

That sounds reasonable. Feel free to submit a PR and thanks for the suggestion.

Which of the three completion options does PSFzf need?

@Nova38
Copy link
Author

Nova38 commented Feb 12, 2025

Yep that is exactly it. It would probably want to use the 'MenuComplete' option.
I'll put together a pr!

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

No branches or pull requests

2 participants