-
Notifications
You must be signed in to change notification settings - Fork 85
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
Experiment: ZSH only version of async files changes #83
base: master
Are you sure you want to change the base?
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=true That 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.git
and spawns an async subshell to populate that file. Then using ZSH'szle reset-prompt
we 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
TRAPUSR1
to your.zshrc
: