Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (58 commits)
  fix(git): add checked-out branch support to `gbg*` (ohmyzsh#12397)
  feat(procs): add completions plugin (ohmyzsh#12406)
  fix(nvm): use `command cat` to avoid alias (ohmyzsh#12410)
  fix(nvm): use `nvm version` when needed (ohmyzsh#12409)
  feat(dependencies): add `wd` (ohmyzsh#12405)
  fix(cli): fix edge cases in `omz plugin disable` command (ohmyzsh#12401)
  feat(nvm): add `corepack` to `lazy_cmd`
  feat(python): autovenv keeps activated on subdirs (ohmyzsh#12396)
  fix(extract): `zst` now extracts as expected (ohmyzsh#12395)
  feat(termsupport): support `alacritty*` TERM (ohmyzsh#12392)
  feat(autojump): add `nix-darwin` install path (ohmyzsh#12389)
  fix(fzf): support old `fzf` versions
  fix(copybuffer): prevent `which` alias usage (ohmyzsh#12379)
  fix(poetry-env): do not deactivate in a subdir
  feat(fishy): add color to username (ohmyzsh#12369)
  fix(ssh-agent): add identity only if identity exists (ohmyzsh#12371)
  chore(async): reenable async prompt by default on zsh < 5.0.6 (ohmyzsh#12358)
  fix(async): fix crash on zsh < 5.0.6 (ohmyzsh#12358)
  feat(fzf): support fzf setup for 0.48.0 and older (ohmyzsh#12367)
  fix(history): add `t` option to history wrapper (ohmyzsh#12365)
  ...
  • Loading branch information
lesterchan committed May 11, 2024
2 parents 33425b6 + 0fabd5f commit 0514368
Show file tree
Hide file tree
Showing 113 changed files with 608 additions and 268 deletions.
8 changes: 8 additions & 0 deletions .github/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ dependencies:
precopy: |
set -e
find . ! -name _gradle ! -name LICENSE -delete
plugins/wd:
repo: mfaerevaag/wd
branch: master
version: tag:v0.6.0
precopy: |
set -e
rm -r test
rm install.sh tty.gif wd.1
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- [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)
- [Getting Updates](#getting-updates)
- [Updates Verbosity](#updates-verbosity)
- [Manual Updates](#manual-updates)
Expand Down Expand Up @@ -361,6 +362,17 @@ Instead, you can now use the following:
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 off 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 -->

> This feature is currently in a testing phase and it may be subject to change in the future.
Expand Down
2 changes: 1 addition & 1 deletion custom/themes/example.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Put your custom themes in this folder.
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
#
#
# Example:

PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
20 changes: 9 additions & 11 deletions lib/async_prompt.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh

zmodload zsh/system
autoload -Uz is-at-least

# For now, async prompt function handlers are set up like so:
# First, define the async function handler and register the handler
Expand Down Expand Up @@ -82,10 +83,8 @@ function _omz_async_request {
exec {fd}< <(
# Tell parent process our PID
builtin echo ${sysparams[pid]}
# Store handler name for callback
builtin echo $handler
# Set exit code for the handler if used
(exit $ret)
() { return $ret }
# Run the async function handler
$handler
)
Expand All @@ -95,11 +94,11 @@ function _omz_async_request {
# There's a weird bug here where ^C stops working unless we force a fork
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
command true
# and https://github.com/zsh-users/zsh-autosuggestions/pull/612
is-at-least 5.8 || command true
# Save the PID from the handler child process
read pid <&$fd
_OMZ_ASYNC_PIDS[$handler]=$pid
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
# When the fd is readable, call the response handler
zle -F "$fd" _omz_async_callback
Expand All @@ -114,19 +113,18 @@ function _omz_async_callback() {
local err=$2 # Second arg will be passed in case of error
if [[ -z "$err" || "$err" == "hup" ]]; then
# Get handler name from first line
local handler
read handler <&$fd
# Get handler name from fd
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
# Store old output which is supposed to be already printed
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
# 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
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
zle reset-prompt
zle .reset-prompt
zle -R
fi
Expand Down
26 changes: 22 additions & 4 deletions lib/cli.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,18 @@ function _omz::plugin::disable {

# Remove plugins substitution awk script
local awk_subst_plugins="\
gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
"

# Disable plugins awk script
local awk_script="
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
Expand Down Expand Up @@ -773,7 +781,17 @@ function _omz::theme::use {
}

function _omz::update {
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
# Check if git command is available
(( $+commands[git] )) || {
_omz::log error "git is not installed. Aborting..."
return 1
}

local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
[[ $? -eq 0 ]] || {
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
return 1
}

# Run update script
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
Expand Down
2 changes: 1 addition & 1 deletion lib/compfix.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function handle_completion_insecurities() {
# /usr/share/zsh/5.0.6
#
# Since the ignorable first line is printed to stderr and thus not captured,
# stderr is squelched to prevent this output from leaking to the user.
# stderr is squelched to prevent this output from leaking to the user.
local -aU insecure_dirs
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )

Expand Down
24 changes: 12 additions & 12 deletions lib/diagnostics.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#
# This is written in a defensive style so it still works (and can detect) cases when
# basic functionality like echo and which have been redefined. In particular, almost
# everything is invoked with "builtin" or "command", to work in the face of user
# everything is invoked with "builtin" or "command", to work in the face of user
# redefinitions.
#
# OPTIONS
Expand Down Expand Up @@ -59,7 +59,7 @@ function omz_diagnostic_dump() {
emulate -L zsh

builtin echo "Generating diagnostic dump; please be patient..."

local thisfcn=omz_diagnostic_dump
local -A opts
local opt_verbose opt_noverbose opt_outfile
Expand Down Expand Up @@ -90,7 +90,7 @@ function omz_diagnostic_dump() {
builtin echo
builtin echo Diagnostic dump file created at: "$outfile"
builtin echo
builtin echo To share this with OMZ developers, post it as a gist on GitHub
builtin echo To share this with OMZ developers, post it as a gist on GitHub
builtin echo at "https://gist.github.com" and share the link to the gist.
builtin echo
builtin echo "WARNING: This dump file contains all your zsh and omz configuration files,"
Expand All @@ -105,8 +105,8 @@ function _omz_diag_dump_one_big_text() {
builtin echo oh-my-zsh diagnostic dump
builtin echo
builtin echo $outfile
builtin echo
builtin echo

# Basic system and zsh information
command date
command uname -a
Expand Down Expand Up @@ -151,7 +151,7 @@ function _omz_diag_dump_one_big_text() {

# Core command definitions
_omz_diag_dump_check_core_commands || return 1
builtin echo
builtin echo

# ZSH Process state
builtin echo Process state:
Expand All @@ -167,7 +167,7 @@ function _omz_diag_dump_one_big_text() {
#TODO: Should this include `env` instead of or in addition to `export`?
builtin echo Exported:
builtin echo $(builtin export | command sed 's/=.*//')
builtin echo
builtin echo
builtin echo Locale:
command locale
builtin echo
Expand All @@ -181,7 +181,7 @@ function _omz_diag_dump_one_big_text() {
builtin echo
builtin echo 'compaudit output:'
compaudit
builtin echo
builtin echo
builtin echo '$fpath directories:'
command ls -lad $fpath
builtin echo
Expand Down Expand Up @@ -224,7 +224,7 @@ function _omz_diag_dump_one_big_text() {
local cfgfile cfgfiles
# Some files for bash that zsh does not use are intentionally included
# to help with diagnosing behavior differences between bash and zsh
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
$zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout
~/.zsh.pre-oh-my-zsh
/etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout )
Expand Down Expand Up @@ -258,8 +258,8 @@ function _omz_diag_dump_check_core_commands() {
# (For back-compatibility, if any of these are newish, they should be removed,
# or at least made conditional on the version of the current running zsh.)
# "history" is also excluded because OMZ is known to redefine that
reserved_words=( do done esac then elif else fi for case if while function
repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
reserved_words=( do done esac then elif else fi for case if while function
repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
)
builtins=( alias autoload bg bindkey break builtin bye cd chdir command
comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
Expand Down Expand Up @@ -331,7 +331,7 @@ function _omz_diag_dump_os_specific_version() {
case "$OSTYPE" in
darwin*)
osname=$(command sw_vers -productName)
osver=$(command sw_vers -productVersion)
osver=$(command sw_vers -productVersion)
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
;;
cygwin)
Expand Down
32 changes: 24 additions & 8 deletions lib/git.zsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
autoload -Uz is-at-least

# The git prompt's git commands are read-only and should not interfere with
# other processes. This environment variable is equivalent to running with `git
# --no-optional-locks`, but falls back gracefully for older versions of git.
Expand All @@ -9,7 +11,7 @@ function __git_prompt_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.
# Otherwise, check for hide-info at global and local repository level
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
Expand Down Expand Up @@ -37,22 +39,33 @@ function _omz_git_prompt_status() {
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}

# Enable async prompt by default unless the setting is at false / no
if zstyle -t ':omz:alpha:lib:git' async-prompt; then
# Use async version if setting is enabled or undefined
if zstyle -T ':omz:alpha:lib:git' async-prompt; then
function git_prompt_info() {
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then
echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]"
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
}

# Conditionally register the async handler, only if it's needed in $PROMPT
# or any of the other prompt variables
function _defer_async_git_register() {
# 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}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
_omz_register_handler _omz_git_prompt_info
;;
esac

case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
_omz_register_handler _omz_git_prompt_status
return
;;
esac

Expand All @@ -65,6 +78,9 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt; then
precmd_functions=(_defer_async_git_register $precmd_functions)
else
function git_prompt_info() {
_omz_git_prompt_info
}
function git_prompt_status() {
_omz_git_prompt_status
}
fi
Expand Down Expand Up @@ -197,7 +213,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"
}

function git_prompt_status() {
function _omz_git_prompt_status() {
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return

# Maps a git status prefix to an internal constant
Expand Down
15 changes: 8 additions & 7 deletions lib/history.zsh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
## History wrapper
function omz_history {
local clear list
zparseopts -E c=clear l=list
# parse arguments and remove from $@
local clear list stamp
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp

if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file
echo -n >| "$HISTFILE"
fc -p "$HISTFILE"
echo >&2 History file deleted.
elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
elif [[ $# -eq 0 ]]; then
# if no arguments provided, show full history starting from 1
builtin fc $stamp -l 1
else
# unless a number is provided, show all history events (starting from 1)
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
# otherwise, run `fc -l` with a custom format
builtin fc $stamp -l "$@"
fi
}

Expand Down
4 changes: 2 additions & 2 deletions lib/termsupport.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function title {
: ${2=$1}

case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*)
print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name
;;
Expand Down Expand Up @@ -129,7 +129,7 @@ fi
# Don't define the function if we're in an unsupported terminal
case "$TERM" in
# all of these either process OSC 7 correctly or ignore entirely
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;;
contour*|foot*) ;;
*)
# Terminal.app and iTerm2 process OSC 7 correctly
Expand Down

0 comments on commit 0514368

Please sign in to comment.