question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fish-like autocompletion

See original GitHub issue

I tried to figure this out but couldn’t find out. Is there a way to get autocompletion like in the fish shell?

fish-shell-demo

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 <kbd>→</kbd> (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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:130
  • Comments:76 (28 by maintainers)

github_iconTop GitHub Comments

83reactions
daxian-dbwcommented, Mar 27, 2020

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!).

PSReadLine.zip

Currently:

  • The only suggestion source is the PSReadLine history. The ultimate goal is to call into a prediction API in S.M.A that is powered by a prediction plugin.
  • Currently there is no way to configure the style that the suggestion text is rendered with, the default style (color only) works OK with a black background. (of course, more work is needed here)
  • VI mode - now the suggestion is disabled when switching to the command mode, and enabled when switching to insert mode.
  • So far, I haven’t really focused on the VI/Emacs experience, so it could be pretty raw, and feedback is very welcome.

When using this PSReadLine, please add the following key binding to your profile:

Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
  • Pressing RightArrow at the end of current typing will accept the suggestion text
  • Pressing Ctrl+f at the end of current typing will accept a word from the suggestion text
  • Pressing Ctrl+z will get you back to where you were before accepting all or part of the suggestion

Important note: don’t forget to unblock the zip file after you download it, otherwise you will face weird exceptions thrown from PowerShell.

predict

27reactions
lzybkrcommented, Feb 26, 2020

@Southclaws - do you already set these bindings (which I think should be changed to be the default)?

Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fish-like autosuggestions for zsh
Key Bindings · autosuggest-accept : Accepts the current suggestion. · autosuggest-execute : Accepts and executes the current suggestion. · autosuggest-clear : ...
Read more >
How to make zsh completion show the first guess on ...
In Fish when you start typing, autocompletion automatically shows the first autocompleted guess on the line itself. In zsh you have to hit ......
Read more >
Fish like autosuggestion commands description in zsh!
How to get description of commands in zsh (autosuggestion) like fish shell (like in the picture: source fish ... [ QUETSION] - Autocompletion....
Read more >
I love fish shell, I love the autocomplete, but I've been ...
I love fish shell, I love the autocomplete, but I've been forced to switch back to bash lately, because fish syntax is just...
Read more >
Writing your own completions
A completion file must have a filename consisting of the name of the command to complete and the suffix .fish . By default,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found