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
I want my pwsh to store the return value of a command in the global variable $ans after running the command.
I've searched high and low for a way to implement it and it looks like the only way is Set-PSReadLineKeyHandler -Key Enter.
And I can't just modify the buffer and call AcceptLine in the EnterKeyHandler, because that would change what's already on the screen. I had to do my own expression evaluation via Invoke-Expression, then record the start and end times, build a structure to pass to Add-History, catch exceptions, and apply a loop to handle the possibility of multiple lines of input......
I'm almost on the verge of handwriting another AcceptLine implementation!
And all I want to do is add a bit of custom logic to the execution of the input.
I would like to add a new handler for additional processing of expressions after AcceptLine has been called without modifying the content on the screen (or taking over the execution process and returning the value)
This might simplify a lot of customisation requirements
We are not going to add a handler like this in PSReadLine.
PowerShell team has been investigating a way to allow user to be able to capture output from native commands, by utilizing PTY, but no ETA for it. If you want to capture output from cmdlets, then see if $PSDefaultParameterValues could be helpful, for example, by setting $PSDefaultParameterValues = @{"*:OutVariable"=myvar}.
Prerequisites
Description of the new feature/enhancement
I want my pwsh to store the return value of a command in the global variable
$ans
after running the command.I've searched high and low for a way to implement it and it looks like the only way is
Set-PSReadLineKeyHandler -Key Enter
.And I can't just modify the buffer and call
AcceptLine
in the EnterKeyHandler, because that would change what's already on the screen. I had to do my own expression evaluation viaInvoke-Expression
, then record the start and end times, build a structure to pass toAdd-History
, catch exceptions, and apply a loop to handle the possibility of multiple lines of input......I'm almost on the verge of handwriting another AcceptLine implementation!
And all I want to do is add a bit of custom logic to the execution of the input.
I would like to add a new handler for additional processing of expressions after AcceptLine has been called without modifying the content on the screen (or taking over the execution process and returning the value)
This might simplify a lot of customisation requirements
Proposed technical implementation details (optional)
The text was updated successfully, but these errors were encountered: