Closed mayurankv closed 7 months ago
At the moment, I am not aware of a problem that can be solved by zsh-defer that cannot be solved better by other means. I can offer you a deal. If you can describe a valid use case for zsh-defer, I'll create a homebrew tap for it. What do you think?
I hope I've not misunderstood another post of yours that I read, but I was under the impression that if one were to use any prompt other than powerlevel10k, without the benefits of instant prompt, zshrc loading times can be the main cause of delay in shell startup times. Were I to decide that I didn't want to use a prompt at all for example, but still want to use zsh autocompletion and other shell tools like autojump etc., then I would have to wait for all of those things to load before I can type (this actually being the main reason I recently switched to p10k). With zsh-defer you could have a similar improvement to instant prompt and thus improve the user experience. As someone who keeps a very rigorous dot file structure, I often source separate scripts in my zshrc based on organisational groupings rather than speed so it would be very handy to choose whether to load slow-initialising zsh tools after the prompt is rendered, thus also speeding up how quickly I can access things like environment variables.
Overall, I would say the reason I want to have it downloaded is for the same reason instant prompt is a desired feature in p10k.
Finally, I'm not aware of these better means, if it is something using more pure zsh, that may not be accessible to relatively inexperienced users like me, or if you are referring to instant prompt, some may not prefer to use p10k or even any prompt at all. In addition, the zsh-bench tool is something that I'm completely unaware of any alternatives to for measuring performance between different setups myself. I hope that clears it up! (Though I completely understand if you'd prefer not to).
It's not a good idea to defer loading of any code that affects how the keys you press get interpreted. For example, if you defer autojump, it'll make the effect of commands invoking autojump non-deterministic. If you defer some kind of completion code, it'll make Tab non-deterministic. In contrast, if you do NOT use zsh-defer, then pressing the same keys will lead to the same result no matter when you press them. You can start zsh and blindly type cd ~/Down<TAB><ENTER>
and expect it to cd
into ~/Downloads
no matter how fast or slow you are at typing. This is true when using p10k instant prompt, too.
Do you have a real life use case for zsh-defer that does not introduce non-deterministic behavior to the shell?
I'm not sure I completely follow, how does instant prompt alleviate this issue? I believe it does this by holding off running the command until everything has loaded in order to make the behaviour consistent. Out of curiosity, what is the intended usage of this utility then? Surely there is no situation in which this wouldn't introduce indeterministicness without some control mechanism?
I'm not sure I completely follow, how does instant prompt alleviate this issue? I believe it does this by holding off running the command until everything has loaded in order to make the behaviour consistent.
That is correct. You can see this if you type ls<ENTER>
quickly enough after starting zsh. You can add sleep 3
to ~/.zshrc
to make this kind of test easier to perform. Note that after the command executes, there is no way to see whether you've typed it while instant prompt was active or after. It looks exactly the same.
Out of curiosity, what is the intended usage of this utility then? Surely there is no situation in which this wouldn't introduce indeterministicness without some control mechanism?
As I mentioned, I am not aware of a valid use case for deferred initialization in zsh. Some people still like to defer stuff, and for them I provide the best implementation in the shape zsh-defer
. I don't encourage its use though.
Ok I understand a bit better thanks. In that case I'm probably fine without it (though I'm always for making things available via brew!).
I'm always for making things available via brew!
It's work to create a tap and to maintain it. I'd rather not do work that I don't see the value of.
Sorry to raise so many issues all at once! This tool, as well as
zsh-bench
, seems really useful for prompt customisation, testing and performance improvements. Would it be possible to have brew taps for them like forgitstatus
andpowerlevel10k
?