Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  Update README for git-prompt to clarify how to use (ohmyzsh#10922)
  fix(autojump): add macOS 'pkgsrc' installation location (ohmyzsh#12329)
  fix(lib/git): fix detection of function use in prompt
  perf(async): avoid executing `true` if not required (ohmyzsh#12318)
  fix(git): disable locally `ksharrays`
  fix(archlinux): make `upgrade` work with non-english
  feat(git): implement async completion for `git_prompt_status` (ohmyzsh#12319)
  feat(git)!: enable async git prompt (now for real)
  fix(async): avoid blocking the shell while waiting (ohmyzsh#12304)
  feat(httpie): complete https command (ohmyzsh#12314)
  feat(gcloud): add homebrew installation path (ohmyzsh#12308)
  fix(starship): keep `ZSH_THEME` if not installed (ohmyzsh#12309)
  style: remove trailing whitespace (ohmyzsh#12303)
  fix(poetry-env): activate only if env exists (ohmyzsh#12301)
  feat(terraform): add `tft` (`terraform test`) (ohmyzsh#12299)
  feat(jira): add help/usage cmd (ohmyzsh#12293)
  fix(ssh-agent): don't start new agent if screen/tmux symlink exists (ohmyzsh#12297)
  • Loading branch information
BougaCaillou committed Apr 8, 2024
2 parents f23b8f8 + bf713e2 commit 3b90955
Show file tree
Hide file tree
Showing 88 changed files with 234 additions and 177 deletions.
12 changes: 12 additions & 0 deletions README.md
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 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 -->

> This feature is currently in a testing phase and it may be subject to change in the future.
Expand Down
6 changes: 3 additions & 3 deletions custom/example.zsh
@@ -1,12 +1,12 @@
# Put files in this folder to add your own custom functionality.
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
#
#
# Files in the custom/ directory will be:
# - loaded automatically by the init script, in alphabetical order
# - loaded last, after all built-ins in the lib/ directory, to override them
# - ignored by git by default
#
#
# Example: add custom/shortcuts.zsh for shortcuts to your local projects
#
#
# brainstormr=~/Projects/development/planetargon/brainstormr
# cd $brainstormr
2 changes: 1 addition & 1 deletion custom/themes/example.zsh-theme
@@ -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%}%% "
18 changes: 8 additions & 10 deletions lib/async_prompt.zsh
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,15 +113,14 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion lib/compfix.zsh
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
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
26 changes: 21 additions & 5 deletions lib/git.zsh
Expand Up @@ -9,7 +9,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 @@ -38,8 +38,16 @@ function _omz_git_prompt_status() {
}

# 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() {
setopt localoptions noksharrays
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then
echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]"
fi
}

function git_prompt_status() {
setopt localoptions noksharrays
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then
echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]"
fi
Expand All @@ -49,10 +57,15 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt; then
# 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
2 changes: 1 addition & 1 deletion oh-my-zsh.sh
Expand Up @@ -152,7 +152,7 @@ unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# zcompile the completion dump file if the .zwc is older or missing.
if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
zrecompile -q -p "$ZSH_COMPDUMP"
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
fi

_omz_source() {
Expand Down
2 changes: 1 addition & 1 deletion plugins/ansible/README.md
Expand Up @@ -28,6 +28,6 @@ plugins=(... ansible)

## Maintainer

### [Deepankumar](https://github.com/deepan10)
### [Deepankumar](https://github.com/deepan10)

[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)
4 changes: 2 additions & 2 deletions plugins/archlinux/archlinux.plugin.zsh
Expand Up @@ -179,8 +179,8 @@ fi
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
function upgrade() {
echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
if [ $installedver != $currentver ]; then
echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade."
Expand Down
1 change: 1 addition & 0 deletions plugins/autojump/autojump.plugin.zsh
Expand Up @@ -13,6 +13,7 @@ autojump_paths=(
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/aws/aws.plugin.zsh
Expand Up @@ -280,7 +280,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
test -s "${AWS_STATE_FILE}" || return

aws_state=($(cat $AWS_STATE_FILE))

export AWS_DEFAULT_PROFILE="${aws_state[1]}"
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
Expand Down
2 changes: 1 addition & 1 deletion plugins/branch/README.md
Expand Up @@ -39,7 +39,7 @@ index 2fd5f2cd..9d89a464 100644
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
```
Expand Down
4 changes: 2 additions & 2 deletions plugins/chruby/chruby.plugin.zsh
Expand Up @@ -2,7 +2,7 @@

_source-from-omz-settings() {
local _chruby_path _chruby_auto

zstyle -s :omz:plugins:chruby path _chruby_path || return 1
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1

Expand All @@ -23,7 +23,7 @@ _source-from-homebrew() {
if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
Expand Down
2 changes: 1 addition & 1 deletion plugins/cloudfoundry/README.md
Expand Up @@ -50,7 +50,7 @@ Alternatively, seek out the [online documentation][3]. And don't forget, there a

## Contributors

Contributed to `oh_my_zsh` by [benwilcock][2].
Contributed to `oh_my_zsh` by [benwilcock][2].

[1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
[2]: https://github.com/benwilcock
Expand Down
2 changes: 1 addition & 1 deletion plugins/coffee/README.md
Expand Up @@ -24,7 +24,7 @@ Also provides the following aliases:
* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
to run the code in a JS console.
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
to compile large/multi-line snippets
* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
Expand Down
4 changes: 2 additions & 2 deletions plugins/compleat/compleat.plugin.zsh
Expand Up @@ -7,14 +7,14 @@

if (( ${+commands[compleat]} )); then
local prefix="${commands[compleat]:h:h}"
local setup="${prefix}/share/compleat-1.0/compleat_setup"
local setup="${prefix}/share/compleat-1.0/compleat_setup"

if [[ -f "$setup" ]]; then
if ! bashcompinit >/dev/null 2>&1; then
autoload -U bashcompinit
bashcompinit -i
fi

source "$setup"
source "$setup"
fi
fi
2 changes: 1 addition & 1 deletion plugins/copybuffer/copybuffer.plugin.zsh
@@ -1,4 +1,4 @@
# copy the active line from the command line buffer
# copy the active line from the command line buffer
# onto the system clipboard

copybuffer () {
Expand Down
2 changes: 1 addition & 1 deletion plugins/dash/README.md
Expand Up @@ -19,7 +19,7 @@ dash

- Query for something in dash app: `dash query`
```
dash golang
dash golang
```

- You can optionally provide a keyword: `dash [keyword:]query`
Expand Down

0 comments on commit 3b90955

Please sign in to comment.