-
Notifications
You must be signed in to change notification settings - Fork 311
Fish-like autocompletion #687
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
Comments
This feature wasn't much of a priority with limited console support for VT sequences, but now Windows has real support for VT sequences, it makes sense to add this capability. |
This type of experience is what we envisioned when we originally thought about "Machine Learning autocompletion". Since then, we dropped the ML part and thought about simply exposing an interface to enable this (https://github.com/PowerShell/PowerShell-RFC/pull/123/files) and just use local history. |
@lzybkr is there any way this is currently already possible with PSReadLine customization? If not, what would be needed to make it possible? It would really improve my workflow so I would be willing to put some work in @SteveL-MSFT So the plan would be to ship a function that handles the searching logic with |
PSReadLine doesn't use Here are my thoughts on implementing this feature:
As for relying on PowerShell for any new fancy suggestions - I'm not excited about that unless it means no api changes. Today a single build of PSReadLine works with any version of PowerShell > 5.0 and I'd like to keep it that way. |
So, is it coming? :D |
Yessss! Please. Looks like there's a whole lot of interest in this. I just saw similar functionality on a livestream and it was awesome! |
I'm working on a prototype of this, and here is the zip package if any of you want to try it (any feedback would be very helpful!). Currently:
When using this PSReadLine, please add the following key binding to your profile:
Important note: don't forget to unblock the zip file after you download it, otherwise you will face weird exceptions thrown from PowerShell. |
This is great to hear! I would love to see the previous pipeline command considered in the prediction. |
@mpearon Can you please elaborate on it a bit more? A screenshot would be useful :) |
@daxian-dbw This isn't the way it is currently behaving (just a suggestion), so there isn't a screenshot to share. Maybe I'm missing the point, but my thought was that when ML is leveraged, the suggestions that it makes (not necessarily from history), should take the previous pipeline item into consideration. |
Yeah, that probably makes sense. I'd generally assume that you could do something like this, suggested in order of importance or probability to be accurate.
I'd also recommend that commands that match either 1 or 3 and are in the same module as the previous command should be suggested first. Any sorting beyond that should probably be related to frequency of usage or just alphabetical perhaps. |
@Southclaws - do you already set these bindings (which I think should be changed to be the default)?
|
Oh, amazing, thanks! Looking forward to the above update too, I'd be interested in testing it out but not sure how to install a module directly from a .zip |
@Southclaws - I wasn't entirely sure how to force PS to default to a different PSReadline module either (short of removing/reimporting the module in a profile, or something). |
@daxian-dbw Are we creating new issues for the preview here? |
@mpearon - try:
|
@mpearon Replacing the original PSReadline directory is the way to use the private zip package. It should be stable enough to not crash. If you decide to get the official PSReadLine module, just use the same "upgrading" instructions from the README.md. Also, if not yet, take a look at https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/SamplePSReadLineProfile.ps1. It contains many useful configurations to PSReadLine from @lzybkr. |
@lzybkr and @daxian-dbw - Those configuration items have corrected the behavior for me! Thank you. |
just wanted to say: Awesome work - Thank you! |
Suggestion seems to stay when switching modes, until an edit is made (then it's removed). I'd like to see it always update even in VI mode personally. Also Very cool though. |
@daxian-dbw FYI I may be messing something up but I think something changed in the latest 2020.3.1 preview and it stopped working in the integrated console. EDIT: And yes I made sure to replace it in the extension modules folder |
I just installed the latest release of Powershell Core 7, is there any way to turn this off/replace the suggested text with the tab-complete text instead of history suggestions? |
@chinmaya1011 that part has not been completed yet, please follow: #1468 And contribute your input for what you would like it to look like if it doesn't meet your needs. |
Hi All - Just found an issue with the autocompletion through an RDP session. Issue created here: #1558 |
I am having an issue with this aswell... I didn't have the "NonInteractive" parameter for my pwsh session before, but I still had this functionality working. Now, all of a sudden, it doesn't work anymore. I have tried to set the "NonInterative" parameter for my pwsh now, but it still doesn't work. I am importing PSReadLine in my profile file (along with oh-my-posh and other things) and it is picking it up when using powershell. But this fish-autocomplete isn't working. |
@Fooughhy can you verify that you are using the new setting? This recently changed to not be on by default, you want to add
|
There we go! I was trying to find a setting for this, but couldn't... Thank you! It works now. One more question, does it require "NonInteractive" as my quoted comment suggested? I guess I could try it out. EDIT: It doesn't seem to be required for me, at least. |
This is so awesome - Have all the awards |
Thank you for the awesome update! BTW, can function |
This is epic! Thanks! |
This is a great new feature. I was looking for it after seeing it on Fish. Thank you for providing it. I've installed 2.2.0 beta1 and have two questions:
Thanks |
@Praful For VI mode, RigthArrow at the end of the editing line will also accept the prediction: You can certainly bind a different key to the As for the color, the example in #1468 was out-dated, see the "Change the Color for Predictions" section in https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/ |
@daxian-dbw thank you for answering my question. For those who want to see the answer in one place, I put the following in my PowerShell profile:
For those who use Vi mode, they may, like me, not want to take their hands off the home keys to reach for the arrow key, the default key to accept the prediction. I have bound that above to Thanks again for making an essential module even better! |
Thanks for your awesome work. BTW, do you plan to support coloring existing cmdlets, functions, script files, or executable programs with green and non-existing ones with red and underlining paths or filenames users input if they are existing just as ZSH's plugin |
i think those are from |
@yihuajack the coloring for existing and non-existing commands seems like a good idea, please open a new issue for this |
Given that the original feature request was finished, I will close this issue. Thank you all for all the feedback and comments! |
Thanks again for this, it's awesome 🤩 |
Agreed, use it constantly, and looks like Github Copilot aped the same style so it's really consistent looking in my vscode experience these days :) |
Now we just need it to be actually powered by GitHub Copilot! ❤️ |
@panekj you can see the API in use in the console logs in vscode, I'm sure it'd be a flagrant license violation but it would be probably to hijack this session and use the API to fetch Powershell completions :) |
Found one way to make this possible:
|
Sorry but how do I turn this off? |
@ToxicSmurf Add this to your profile script to disable predictions: Set-PSReadLineOption -PredictionSource None |
UpArrow HistorySearchBackward Search for the previous item in the history that starts with the current input - This is only working for history matches that begin with the string not containing the string the way fish shell supports. Reading the chord binding description in PSReadline, this appears to be intentional. example:
The only way to find this via HistorySearch is by first typing $ and clicking the UpArrow. Typing Version or PSReadLine or Module etc. does not work, please look into adding this functionality if time permits. Regards, |
You method do not work perfect. When cursor is at the begin, "Ctrl+e" leads to complete the prediction, not to the end of line. I fix it by this sciprt Set-PSReadLineKeyHandler -Key 'Ctrl+e' `
-BriefDescription "Go to EndOfLine or AcceptSuggestion" `
-LongDescription `
"If cursor is not at the end of line, then go to end of line, `
otherwise try to AcceptSuggestion" `
-ScriptBlock {
$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
if ($cursor -ne $line.Length) {
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
} else {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptSuggestion()
}
} |
@owenstake Thank you!! It save me a lot of time !!😄 |
I tried to figure this out but couldn't find out. Is there a way to get autocompletion like in the fish shell?
Basically what I am looking for is automatically searching the history on every keystroke, then showing a grey suggestion behind the cursor that can be accepted with → (if the cursor is at the end of the line).
We can get close with
Set-PSReadLineKeyHandler -Key ArrowRight -Function HistorySearchBackward
but it doesn't show the suggestion and it prevents moving the cursor to the right.The text was updated successfully, but these errors were encountered: