Experiment: ZSH only version of async files changes#83
Experiment: ZSH only version of async files changes#83michaeldfallen wants to merge 12 commits intomasterfrom
Conversation
|
Will this feature be optional? I am already calling git-radar asynchronously in my zsh theme slimline and rely on git-radar being synchronous. |
|
@mgee it was your link to slimline that inspired me to attempt this. I would intend to make this a feature flag that can be turned on or off. Async bash would end up redisplaying only after a second prompt render, which could be annoying, and zsh async would require you to do further work to use it, which some might miss. So I wouldn't want to make this the default either. |
e074fac to
7d46f27
Compare
|
Ok, I've cleaned this up and applied it to the rest of the prompt. Now every part is constructed asynchronously and the prompt is refreshed multiple times. There's still work to do to make the interface for the refresh work properly so I haven't added that in just yet. If you want to test this out add the following to your function TRAPUSR1() {
RPROMPT="$(date)"
# redisplay
export GIT_RADAR_REDRAW=true
zle && zle reset-prompt
export GIT_RADAR_REDRAW=false
}
export GIT_RADAR_ZSH_PID="$(echo $$)"
export GIT_RADAR_ASYNC_EXEC=trueThat will cause the prompt to be rerendered when a I plan to make that interface as easy as |
This pull request is an experiment. If you use ZSH please pull it and try it out as I'm looking for feedback.
In this pull request I have taken the longest part of the radar, the file changes (0.245s out of 0.25s on my machine), and made it async. It now
cat's a file in.gitand spawns an async subshell to populate that file. Then using ZSH'szle reset-promptwe are able to cause the shell to re-render once the async subshell has completed.It's flaky and hacky and only a first pass but it does mean the initial prompt render is almost instantaneous. The file changes then asynchronously populate later.
To use:
You need to add a definition for the zsh function
TRAPUSR1to your.zshrc: