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
Hey, does anyone know if/how it may be possible to insert text into the buffer without accepting/clearing it?
More Details
Ideally, I want to insert some multi-line text into the prompt but still allow for further editing of that text.
Specifically, I'm using PowerShell v7 on Win11 in Windows Terminal and already have the ability to paste a multi-line blob of text into my prompt without invoking the command/text.
So for instance, if I copy/paste this code into my prompt:
0..9|%{
Write-Host"i=$_"# No closing bracket here
I am still able to use my arrow keys to move around & edit the text before invoking it via enter key (once all statements are terminated, otherwise a blank line is inserted).
I'm trying to recreate that same behavior but obviously not using the clipboard and instead via a PowerShell function I'm writing that would call the static methods from this lib.
What I've Tried
I've gone thru the examples in this repo (which are really cool btw), and I thought it would be as simple as using the [Microsoft.PowerShell.PSConsoleReadLine]::Insert("0..9 |%{ $_") or ::Replace(string) methods, but alas, I'm struggling to keep the buffer open at all.
Once I insert text with either of those methods, I can't seem to prevent the prompt from immediately clearing the buffer.
Anyone have any suggestions? Thanks in advance!
PS. This is a small part of a PowerShell module I'm working on that seeks to simulate some of the behavior of the fish shell. Specifically, its funced utility & built-in editor which allows you to very quickly create/edit user-defined functions in your prompt.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey, does anyone know if/how it may be possible to insert text into the buffer without accepting/clearing it?
More Details
Ideally, I want to insert some multi-line text into the prompt but still allow for further editing of that text.
Specifically, I'm using PowerShell v7 on Win11 in Windows Terminal and already have the ability to paste a multi-line blob of text into my prompt without invoking the command/text.
So for instance, if I copy/paste this code into my prompt:
I am still able to use my arrow keys to move around & edit the text before invoking it via enter key (once all statements are terminated, otherwise a blank line is inserted).
I'm trying to recreate that same behavior but obviously not using the clipboard and instead via a PowerShell function I'm writing that would call the static methods from this lib.
What I've Tried
I've gone thru the examples in this repo (which are really cool btw), and I thought it would be as simple as using the
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("0..9 |%{ $_")
or::Replace(string)
methods, but alas, I'm struggling to keep the buffer open at all.Once I insert text with either of those methods, I can't seem to prevent the prompt from immediately clearing the buffer.
Anyone have any suggestions? Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions