Skip to content

Lazy loading segments or async execution #6094

Open
@maratori

Description

@maratori

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see added?

I work with a large monorepo where running git status takes around 4 seconds to complete. Currently, Oh-My-Posh is not designed for handling such scenarios. To work around this, I’ve used the untracked_modes property (alternatively, ignore_status property can be used):

version: 3
blocks:
  - type: prompt
    segments:
      - type: git
        style: plain
        properties:
          untracked_modes:
            /path/to/monorepo: no

While this approach improves performance, it comes at the cost of losing some key pieces of information in the prompt.

Meanwhile, Oh My Zsh handles such cases seamlessly by leveraging an async prompt.

I propose adding similar asynchronous support to Oh-My-Posh. The key idea is as follows:

  • If the execution time of a segment exceeds a configurable threshold (e.g., X milliseconds):
    • Display the prompt immediately with cached output for the slow segment.
    • Continue executing the segment in the background and update the cache when the result is ready.
    • Use the updated result from the background process in the next prompt rendering.

This enhancement, especially when combined with periodic refreshing (#5036), would significantly improve the user experience.
Additionally, it could serve as an alternative to p10k-like instant prompts (#5310).

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions