mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 05:59:46 +08:00
Compare commits
No commits in common. "04007a0e5d0a458efff23da896cf70dc40df585d" and "6dfa9507ce0eb0f4d386bd03268e33943ea55c0f" have entirely different histories.
04007a0e5d
...
6dfa9507ce
12
README.md
12
README.md
@ -43,7 +43,6 @@ 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)
|
||||||
@ -362,17 +361,6 @@ 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,8 +82,10 @@ 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
|
||||||
() { return $ret }
|
(exit $ret)
|
||||||
# Run the async function handler
|
# Run the async function handler
|
||||||
$handler
|
$handler
|
||||||
)
|
)
|
||||||
@ -96,7 +98,8 @@ 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 -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
read pid <&$fd
|
||||||
|
_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
|
||||||
@ -111,14 +114,15 @@ 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 fd
|
# Get handler name from first line
|
||||||
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
local handler
|
||||||
|
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
|
||||||
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
_OMZ_ASYNC_OUTPUT[$handler]="$(cat <&$fd)"
|
||||||
|
|
||||||
# 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_info() {
|
function _omz_git_prompt_status() {
|
||||||
# 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,14 +38,8 @@ function _omz_git_prompt_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 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
|
||||||
@ -57,13 +51,8 @@ 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
|
||||||
|
|
||||||
@ -76,9 +65,6 @@ 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
|
||||||
@ -211,7 +197,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 _omz_git_prompt_status() {
|
function 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 https
|
#compdef http
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# 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