You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several user requests to provide tab completion options for various things. Examples include: #16747 #3118 #10064 #14337
Tab completion already includes a couple of options like [bool] RelativePaths and [bool]IgnoreHiddenShares but the current way to set such options is hard to discover and inconvenient to change on the fly.
For people that don't know, you need to modify the TabExpansion2 so both CompleteInput method calls use a hashtable with all the desired options set. There is an options parameter but if you try to set the default value there it gets ignored when you call TabExpansion2 with your tab key.
Add a new variable similar to $PSStyle that contains all tabexpansion options, it could be called $PSTabExpansionOptions.
Another option would be to add 2 commands: Get-TabExpansionOption and Set-TabExpansionOption.
👍 re centralizing tab-completion customizations in principle, but surfacing them (publicly) in PowerShell itself strikes me as the wrong place; instead, they should be surfaced via PSReadLine or via PSES - see also: #18942 (comment)
Add a new variable similar to $PSStyle that contains all tabexpansion options, it could be called $PSTabExpansionOptions. Another option would be to add 2 commands: Get-TabExpansionOption and Set-TabExpansionOption.
Is it conceivable we would ever get tab-completion for a subset of native commands? I find it slightly odd that Powershell cannot tab-complete for pwsh. Other candidates would be commands that cmdlets call down to, like the DISM cmdlets. If I use dism.exe, Powershell won't help by tab-completion, even though it knows (in a sense) how to. Hypothetically: Set-TabExpansionOption -KnownExecutables $true
Andrew74L, providing tab-completion for an open-ended set of external CLIs is obviously impossible for PowerShell to provide itself (though you could argue that for pwsh itself it should indeed be built in).
Third-party, community-supported projects are the solution - see the posh-cli module (repository is here).
Michael Klement (@mklement0) The problem with that approach is that every time a new option is added every interactive host author needs to update their app separately, and for editors that are no longer maintained (like ISE) you just lose the ability to set new options.
In the case of PSReadline it could also cause some confusion if people are running an older version of PowerShell with a new version of PSReadline and see a new feature that is unavailable to them.
PSReadLine is (a) the module that provides the interactive command-line editing experience, and (b) is bundled with PowerShell.
Yes, the fact that you can update PSReadLineindependently of PowerShell is problematic (a problem that already affects Windows PowerShell with Set-PSReadLineOption -PredictionSource, for instance).
But I think that would be outweighed by the confusion that controlling the interactive experience in two distinct places, with different syntax would invite.
Activity
mklement0 commentedon Jan 17, 2023
👍 re centralizing tab-completion customizations in principle, but surfacing them (publicly) in PowerShell itself strikes me as the wrong place; instead, they should be surfaced via
PSReadLineor via PSES - see also: #18942 (comment)Andrew74L commentedon Jan 17, 2023
Is it conceivable we would ever get tab-completion for a subset of native commands? I find it slightly odd that Powershell cannot tab-complete for pwsh. Other candidates would be commands that cmdlets call down to, like the DISM cmdlets. If I use dism.exe, Powershell won't help by tab-completion, even though it knows (in a sense) how to. Hypothetically:
Set-TabExpansionOption -KnownExecutables $truemklement0 commentedon Jan 17, 2023
Andrew74L, providing tab-completion for an open-ended set of external CLIs is obviously impossible for PowerShell to provide itself (though you could argue that for
pwshitself it should indeed be built in).Third-party, community-supported projects are the solution - see the posh-cli module (repository is here).
Andrew74L commentedon Jan 17, 2023
Thanks Michael
MartinGC94 commentedon Jan 18, 2023
Michael Klement (@mklement0) The problem with that approach is that every time a new option is added every interactive host author needs to update their app separately, and for editors that are no longer maintained (like ISE) you just lose the ability to set new options.
In the case of PSReadline it could also cause some confusion if people are running an older version of PowerShell with a new version of PSReadline and see a new feature that is unavailable to them.
mklement0 commentedon Jan 18, 2023
PSReadLineis (a) the module that provides the interactive command-line editing experience, and (b) is bundled with PowerShell.Yes, the fact that you can update
PSReadLineindependently of PowerShell is problematic (a problem that already affects Windows PowerShell withSet-PSReadLineOption -PredictionSource, for instance).But I think that would be outweighed by the confusion that controlling the interactive experience in two distinct places, with different syntax would invite.