mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-12 20:21:02 +01:00
feat(git): add escape hatch to enable async prompt
This commit is contained in:
parent
0a6f88ba06
commit
2a109d30af
2 changed files with 26 additions and 2 deletions
12
README.md
12
README.md
|
@ -48,7 +48,7 @@ Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
|||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
||||
- [Skip Aliases](#skip-aliases)
|
||||
- [Disable async git prompt](#disable-async-git-prompt)
|
||||
- [Async git prompt](#async-git-prompt)
|
||||
- [Getting Updates](#getting-updates)
|
||||
- [Updates Verbosity](#updates-verbosity)
|
||||
- [Manual Updates](#manual-updates)
|
||||
|
@ -415,7 +415,7 @@ zstyle ':omz:lib:directories' aliases no
|
|||
> It is also not currently aware of "aliases" that are defined as functions. Example of such are `gccd`,
|
||||
> `ggf`, or `ggl` functions from the git plugin.
|
||||
|
||||
### Disable async git prompt
|
||||
### Async git prompt
|
||||
|
||||
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render
|
||||
prompt information asynchronously. This can improve prompt rendering performance, but it might not work well
|
||||
|
@ -426,6 +426,14 @@ turn it off by setting the following in your .zshrc file, before Oh My Zsh is so
|
|||
zstyle ':omz:alpha:lib:git' async-prompt no
|
||||
```
|
||||
|
||||
If your problem is that the git prompt just stopped appearing, you can try to force it setting the following
|
||||
configuration before `oh-my-zsh.sh` is sourced. If it still does not work, please open an issue with your
|
||||
case.
|
||||
|
||||
```sh
|
||||
zstyle ':omz:alpha:lib:git' async-prompt force
|
||||
```
|
||||
|
||||
## Getting Updates
|
||||
|
||||
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by
|
||||
|
|
16
lib/git.zsh
16
lib/git.zsh
|
@ -44,6 +44,7 @@ function _omz_git_prompt_info() {
|
|||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12331
|
||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12360
|
||||
# TODO(2024-06-12): @mcornella remove workaround when CentOS 7 reaches EOL
|
||||
local _style
|
||||
if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
||||
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
|
||||
function git_prompt_info() {
|
||||
|
@ -81,6 +82,21 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
|||
# Register the async handler first. This needs to be done before
|
||||
# the async request prompt is run
|
||||
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||
elif zstyle -s ':omz:alpha:lib:git' async-prompt _style && [[ $_style == "force" ]]; then
|
||||
function git_prompt_info() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_prompt_status() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||
fi
|
||||
}
|
||||
|
||||
_omz_register_handler _omz_git_prompt_info
|
||||
_omz_register_handler _omz_git_prompt_status
|
||||
else
|
||||
function git_prompt_info() {
|
||||
_omz_git_prompt_info
|
||||
|
|
Loading…
Reference in a new issue