Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading segments or async execution #6094

Open
1 task done
maratori opened this issue Jan 14, 2025 · 2 comments
Open
1 task done

Lazy loading segments or async execution #6094

maratori opened this issue Jan 14, 2025 · 2 comments
Assignees
Labels
🚀 feat New feature

Comments

@maratori
Copy link

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

@JanDeDobbeleer
Copy link
Owner

@maratori this is a very challenging feature as oh-my-posh isn't shell native. It can be achieved, but nowhere near easily. And unfortunately that's one of these features where I simply don't have the time until this project's funding allows me to partially quit my day job.

@maratori
Copy link
Author

this is a very challenging feature ...

Yes, I agree.

... as oh-my-posh isn't shell native.

Can you please clarify what you mean and how it relates to this feature?

And unfortunately that's one of these features where I simply don't have the time until this project's funding allows me to partially quit my day job.

I completely understand your time constraints. Perhaps I could work on implementing this feature. However, we would need to design it first, as there are several key design decisions to address before creating a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feat New feature
Projects
None yet
Development

No branches or pull requests

2 participants