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

p10k-like instant prompt #5310

Open
1 task done
TheColorman opened this issue Jul 19, 2024 · 11 comments
Open
1 task done

p10k-like instant prompt #5310

TheColorman opened this issue Jul 19, 2024 · 11 comments
Assignees
Labels
🚀 feat New feature

Comments

@TheColorman
Copy link

Code of Conduct

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

What would you like to see added?

Some segments can take a long time to load, such as the Last.fm music segment, as it has to complete an http request, or segments that run custom shell commands/scripts. This can slow down the load time considerably. powerlevel10k has a feature called "instant shell" that allows you to start typing your command while different zsh plugins load.

A similar feature that allows you to type immediately, then loads each segment independently would go a long way to make the shell feel a lot faster. With the Last.fm example, every segment would practically load instantly, allowing you to start typing, only for the Last.fm segment to appear whenever it is ready.

#2861 suggests a similar feature for PowerShell, but the feasibility of the implementation was never discussed.

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Jul 19, 2024

@TheColorman this isn't practically possible as unlike p10k, we're not running directly in the shell. There's no way to return a string at the same time as processing long commands in the background. Additionally, even if, we would need to render the entire prompt again as conditional colors and segment chaining depends on all active segments, you can't stitch something in between.

You also need a way to report back as how can oh-my-posh let the shell know it's done processing to reload the prompt, that's quite the challenge (not sure if this can be solved even due to it not being shell native).

You can set up fast loading on PowerShell by wrapping the oh-my-posh init line inside a prompt function, but that would be done in your $profile rather than oh-my-posh.

@TheColorman
Copy link
Author

TheColorman commented Jul 19, 2024

That makes sense, guess there's no good solution for asynchronous segments like last.fm for now then. I'm not that familiar with go (or shell plugins/renderers for that matter), so I wasn't quite sure how omp works under the hood. I don't use PowerShell myself (I'm on zsh), but I'll keep it in mind if I ever need to, because I really like omp!

I guess that closes the issue then?

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Jul 19, 2024

@TheColorman what if we create a feature that allows you to define an instant prompt (like transient) and we load that one fast, then asynchronously create the actual prompt and replace when done?

@TheColorman
Copy link
Author

If that's possible that would definitely fit any of my use cases. Something like the configuration for the transient prompt, but for an instant prompt?

@luxus
Copy link

luxus commented Aug 25, 2024

i switched from p10k and miss instantprompt :D

@feekApp
Copy link

feekApp commented Aug 28, 2024

same here, for example open new TMUX session and do some send-keys commands:

tmux new-session -s session_name -n PANE -d
tmux send-keys -t session_name:PANE "cd ProjectDirectory" Enter
tmux send-keys -t session_name:PANE "vim" Enter

without an instant prompt, the send-keys commands are not executed, but prompted in the new session. I have to set a delay in my scripts in order to make my TMUX scripts working again using Oh My Posh.

So an adding a kind of instant prompt would be much appreciated.

@feekApp
Copy link

feekApp commented Sep 13, 2024

As @JanDeDobbeleer mentioned in #5524 these additional settings:

"disable_notice": true,
"auto_upgrade": false

solves my issue with not loaded commands.

@isapir
Copy link

isapir commented Sep 21, 2024

I was so happy to find oh-my-posh but after trying it for a bit this issue is a deal breaker for me and I will have to go back to p10k if a solution is not found.

@feekApp Where did you set these settings?

@feekApp
Copy link

feekApp commented Sep 21, 2024

@isapir first lines of my .toml file

disable_notice = true
auto_upgrade = false

@isapir
Copy link

isapir commented Sep 21, 2024

Thanks @feekApp. I'm not sure that I see a difference but I'll give it a try (first 5 runs are with this config and the last 5 runs are with default):
image

@isapir
Copy link

isapir commented Sep 21, 2024

I think that it works fine with that change. The way I "test" this is by opening a terminal window and immediately typing which zsh. Without the update the first few characters would be missed and I would get an error because the command would be something like ich zsh, which would obviously fail.

Now it keeps those characters as can be seen in the screenshot:
image

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

5 participants