mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 05:59:46 +08:00
Compare commits
4 Commits
6dfa9507ce
...
04007a0e5d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04007a0e5d | ||
|
|
ec1afe9dd6 | ||
|
|
b43b84abc7 | ||
|
|
130002a79e |
12
README.md
12
README.md
@ -43,6 +43,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
|||||||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
||||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
||||||
- [Skip Aliases](#skip-aliases)
|
- [Skip Aliases](#skip-aliases)
|
||||||
|
- [Disable async git prompt](#disable-async-git-prompt)
|
||||||
- [Getting Updates](#getting-updates)
|
- [Getting Updates](#getting-updates)
|
||||||
- [Updates Verbosity](#updates-verbosity)
|
- [Updates Verbosity](#updates-verbosity)
|
||||||
- [Manual Updates](#manual-updates)
|
- [Manual Updates](#manual-updates)
|
||||||
@ -361,6 +362,17 @@ Instead, you can now use the following:
|
|||||||
zstyle ':omz:lib:directories' aliases no
|
zstyle ':omz:lib:directories' aliases no
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Disable async git prompt
|
||||||
|
|
||||||
|
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information
|
||||||
|
asyncronously. This can improve prompt rendering performance, but it might not work well with some setups. We hope that's not an
|
||||||
|
issue, but if you're seeing problems with this new feature, you can turn it of by setting the following in your .zshrc file,
|
||||||
|
before Oh My Zsh is sourced:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zstyle ':omz:alpha:lib:git' async-prompt no
|
||||||
|
```
|
||||||
|
|
||||||
#### Notice <!-- omit in toc -->
|
#### Notice <!-- omit in toc -->
|
||||||
|
|
||||||
> This feature is currently in a testing phase and it may be subject to change in the future.
|
> This feature is currently in a testing phase and it may be subject to change in the future.
|
||||||
|
|||||||
@ -82,10 +82,8 @@ function _omz_async_request {
|
|||||||
exec {fd}< <(
|
exec {fd}< <(
|
||||||
# Tell parent process our PID
|
# Tell parent process our PID
|
||||||
builtin echo ${sysparams[pid]}
|
builtin echo ${sysparams[pid]}
|
||||||
# Store handler name for callback
|
|
||||||
builtin echo $handler
|
|
||||||
# Set exit code for the handler if used
|
# Set exit code for the handler if used
|
||||||
(exit $ret)
|
() { return $ret }
|
||||||
# Run the async function handler
|
# Run the async function handler
|
||||||
$handler
|
$handler
|
||||||
)
|
)
|
||||||
@ -98,8 +96,7 @@ function _omz_async_request {
|
|||||||
command true
|
command true
|
||||||
|
|
||||||
# Save the PID from the handler child process
|
# Save the PID from the handler child process
|
||||||
read pid <&$fd
|
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
||||||
_OMZ_ASYNC_PIDS[$handler]=$pid
|
|
||||||
|
|
||||||
# When the fd is readable, call the response handler
|
# When the fd is readable, call the response handler
|
||||||
zle -F "$fd" _omz_async_callback
|
zle -F "$fd" _omz_async_callback
|
||||||
@ -114,15 +111,14 @@ function _omz_async_callback() {
|
|||||||
local err=$2 # Second arg will be passed in case of error
|
local err=$2 # Second arg will be passed in case of error
|
||||||
|
|
||||||
if [[ -z "$err" || "$err" == "hup" ]]; then
|
if [[ -z "$err" || "$err" == "hup" ]]; then
|
||||||
# Get handler name from first line
|
# Get handler name from fd
|
||||||
local handler
|
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
||||||
read handler <&$fd
|
|
||||||
|
|
||||||
# Store old output which is supposed to be already printed
|
# Store old output which is supposed to be already printed
|
||||||
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||||
|
|
||||||
# Read output from fd
|
# Read output from fd
|
||||||
_OMZ_ASYNC_OUTPUT[$handler]="$(cat <&$fd)"
|
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
||||||
|
|
||||||
# Repaint prompt if output has changed
|
# Repaint prompt if output has changed
|
||||||
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
||||||
|
|||||||
22
lib/git.zsh
22
lib/git.zsh
@ -9,7 +9,7 @@ function __git_prompt_git() {
|
|||||||
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz_git_prompt_status() {
|
function _omz_git_prompt_info() {
|
||||||
# If we are on a folder not tracked by git, get out.
|
# If we are on a folder not tracked by git, get out.
|
||||||
# Otherwise, check for hide-info at global and local repository level
|
# Otherwise, check for hide-info at global and local repository level
|
||||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
||||||
@ -38,8 +38,14 @@ function _omz_git_prompt_status() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Enable async prompt by default unless the setting is at false / no
|
# Enable async prompt by default unless the setting is at false / no
|
||||||
if zstyle -t ':omz:alpha:lib:git' async-prompt; then
|
if zstyle -T ':omz:alpha:lib:git' async-prompt; then
|
||||||
function git_prompt_info() {
|
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
|
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then
|
||||||
echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]"
|
echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]"
|
||||||
fi
|
fi
|
||||||
@ -51,8 +57,13 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt; then
|
|||||||
# Check if git_prompt_info is used in a prompt variable
|
# Check if git_prompt_info is used in a prompt variable
|
||||||
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
||||||
|
_omz_register_handler _omz_git_prompt_info
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
|
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
|
||||||
_omz_register_handler _omz_git_prompt_status
|
_omz_register_handler _omz_git_prompt_status
|
||||||
return
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -65,6 +76,9 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt; then
|
|||||||
precmd_functions=(_defer_async_git_register $precmd_functions)
|
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||||
else
|
else
|
||||||
function git_prompt_info() {
|
function git_prompt_info() {
|
||||||
|
_omz_git_prompt_info
|
||||||
|
}
|
||||||
|
function git_prompt_status() {
|
||||||
_omz_git_prompt_status
|
_omz_git_prompt_status
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
@ -197,7 +211,7 @@ function git_prompt_long_sha() {
|
|||||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_status() {
|
function _omz_git_prompt_status() {
|
||||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||||
|
|
||||||
# Maps a git status prefix to an internal constant
|
# Maps a git status prefix to an internal constant
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#compdef http
|
#compdef http https
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user