Suggestion: support inline previews of tab completions
See original GitHub issueNote: The suggested feature may have to be constrained to certain types of completions, and it is debatable whether it should be the default behavior or opt-in via a new option, but overall I think it would greatly streamline the tab-completion experience.
Imagine if PSReadLine showed you a preview of what the token you’re currently typing would expand to if you pressed <kbd>Tab</kbd> at that moment; e.g.:
That is, having typed parameter-name prefix -Fo
, PSReadLine would show you, via the differently colored - “rce” part, that if you pressed <kbd>Tab</kbd> at that moment you’d end up with -Force
.
If the preview doesn’t indicate the desired parameter, simply keep typing until the desired one is suggested; e.g., additionally type an l
to make the preview show “lowSymlink” to inform you that pressing <kbd>Tab</kbd> then would complete to -FollowSymlink
.
This makes for a very convenient experience if you know what exactly what completion you’re looking for : just keep typing - without interruption - until you see what you want, then press <kbd>Tab</kbd>.
A challenge is how to handle transitioning to reviewing all possible completions at a given point, given that pressing <kbd>Tab</kbd> in this scenario would have to result in instant completion (whereas currently you can use it to cycle through the candidate completions).
-
If technically feasible, pressing <kbd>Tab</kbd> right after a completion would still be aware of what prefix was actually typed and would still allow cycling through the possible completions.
-
Alternatively / complementarily, a separate key chord such as <kbd>Ctrl + Tab</kbd>could be used to show all possibly completions in a menu, via built-in function
MenuComplete
.
As an aside: If someone prefers the current tab-completion behavior in principle, but would like to show a menu of possible completions in case of ambiguity, they can add the following to your $PROFILE
:
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Environment data
PS version: 6.1.0-preview.4
PSReadline version: 2.0.0-beta2
os: 10.0.16299.15 (WinBuild.160101.0800)
PS file version: 6.1.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (1 by maintainers)
One more thing, because it may not be obvious (should someone in the future stumble upon this thread): plugins (completer modules) must be imported explicitly into every session (via
$PROFILE
) - PSReadLine, at last as of v2.2.6, does not try to discover and load them automatically (for performance reasons, I presume).The plugin https://github.com/PowerShell/CompletionPredictor adds (If I understand correctly) “syntax-based completions”. In PSReadLine 2.2.6,
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
is the default, so installing and importing that module should be sufficient to resolve this ticket.(And I can see that’s happening in parallel as I comment)