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.

Feature Request - "pre" execution functionality

See original GitHub issue

Summary of the new feature/enhancement

Ability to have a version of the prompt function that can run prior to each command being run in the command line & allow changing of the prompt within it

This would allow for example for a series of actions to set items in the prompt and host prior to execution (like when you kicked off a command, particularly any long running command)

Proposed technical implementation details (optional)

a mirroring of the prompt function but instead runs before the command issued at the terminal is actually run.

function preprompt {
    Write-Host "[" -NoNewline
    Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline
    Write-Host "] [" -NoNewline
    }

The above would on each execution update the prompt with the time that the command was executed at The same code used in the prompt function below update the prompt with the time that the command was completed at

function prompt {
    Write-Host "[" -NoNewline
    Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline
    Write-Host "] [" -NoNewline
    }

Having both is useful for transcriptions/interactive glances/ long running processes & would be a useful improvement to the engine

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
daxian-dbwcommented, Jun 26, 2021

The ask is a function to run before an accepted command line gets executed, so change the title to differentiate from #15104, which asks for a way to call custom functions before evaluating the ‘Prompt’ function.

1reaction
SeeminglySciencecommented, Dec 28, 2020

A way to lessen this pollution would be to offer a way to redraw the prompt string in place: Say you submit Get-Date at prompt PS C:\> and just before execution the entire command line is reprinted in place as, e.g., PS C:\ [launched at 12/28/2020 11:31:12]> Get-Date

That’s not impossible, but that would be a very challenging work item to make consistent. You’d have to keep track of exactly how much the prompt initially wrote, clear it, re-write it, and then force PSRL to re-render. Also every custom PSHost would have to copy that logic, as prompt processing is currently left to the host. Add in how different terminal emulators process these types of escape sequences a little bit differently and it’s hard to imagine this being implemented consistently.

If so, the question is: is this technically feasible, in a manner that doesn’t disrupt transcripts?

I think the only feasible option transcript wise would be to just write the re-rendered prompt normally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request: pre-exec hook · Issue #15271
basically the idea is to have a hook function that will execute just before the command is executed, and this function will know...
Read more >
Speed up development with a free feature request template
Get a free feature request template to help you gather product feedback throughout development for a fast and smooth process.
Read more >
Product Feature Requests: Tips to Manage & Respond ...
A product feature request is a condition where a customer, instead of telling their problem starts suggesting some features that your SaaS ...
Read more >
Feature Requests: How to Track, Prioritize, and Manage
Using a feature request system centralizes incoming requests for product updates and new features. This ensures that everyone managing the ...
Read more >
What is a Feature Request? Understanding User Feedback
Feature requests are ideas, comments, messages, or specific customer inquiries asking for a particular function to be added to your product.
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