Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (90 commits)
  feat(gradle): update completion to version 25da917c (ohmyzsh#12287)
  fix(dependencies): copy gradle LICENSE
  feat(dependencies): enable gradle plugin
  docs: fix typos (ohmyzsh#12284)
  docs(pyenv): fix typo (ohmyzsh#12283)
  feat(extract): prefer using `pbzip2` instead of `bunzip2` (ohmyzsh#12280)
  docs(readme): add contributor list (ohmyzsh#12236)
  feat(fzf): add default fzf_base for msys2 (ohmyzsh#12274)
  fix(async): register the git prompt async handler correctly (ohmyzsh#12267)
  fix(git): disable temporarely async prompt
  feat(async)!: implement async prompt API and apply to git prompt (ohmyzsh#12257)
  feat(tools): update `supports_hyperlinks` (ohmyzsh#12258)
  chore(gitfast): remove update script (ohmyzsh#12262)
  perf(nvm): don't call `nvm version` on every cd
  feat(nvm)!: make `lazy` and `autoload` options compatible
  fix(nvm): remove zsh completion
  fix(terraform): fix completion repeating flags with value (ohmyzsh#12256)
  fix(terraform): pass `-chdir` to completion commands (ohmyzsh#12254)
  feat(python): add auto venv activation (ohmyzsh#12248)
  feat(terraform): update completion to `v1.7` (ohmyzsh#12252)
  ...
  • Loading branch information
lesterchan committed Mar 16, 2024
2 parents ba7819b + d0bddee commit 33425b6
Show file tree
Hide file tree
Showing 99 changed files with 2,335 additions and 1,674 deletions.
5 changes: 3 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,13 +1,14 @@
# Plugin owners
plugins/archlinux/ @ratijas
plugins/dbt/ @msempere
plugins/eza/ @pepoluan
plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec
plugins/react-native @esthor
plugins/sdk/ @rgoldberg
plugins/shell-proxy/ @septs
plugins/starship/ @axieax
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza
plugins/starship/ @axieax
plugins/dbt/ @msempere
12 changes: 12 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
day: "sunday"
- package-ecosystem: "pip"
directory: "/.github/workflows/dependencies"
schedule:
interval: "weekly"
day: "sunday"
22 changes: 20 additions & 2 deletions .github/dependencies.yml
Expand Up @@ -2,19 +2,37 @@ dependencies:
plugins/gitfast:
repo: felipec/git-completion
branch: master
version: tag:v1.3.7
version: tag:v2.1
postcopy: |
set -e
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
test -e git-completion.zsh && mv -f git-completion.zsh _git
plugins/z:
branch: master
repo: agkozak/zsh-z
version: 6bfe418332866d15373392164df11b4fbec2083f
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
precopy: |
set -e
test -e README.md && mv -f README.md MANUAL.md
postcopy: |
set -e
test -e _zshz && mv -f _zshz _z
test -e zsh-z.plugin.zsh && mv -f zsh-z.plugin.zsh z.plugin.zsh
plugins/history-substring-search:
repo: zsh-users/zsh-history-substring-search
branch: master
version: 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64
precopy: |
set -e
rm -f zsh-history-substring-search.plugin.zsh
test -e zsh-history-substring-search.zsh && mv zsh-history-substring-search.zsh history-substring-search.zsh
postcopy: |
set -e
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
plugins/gradle:
repo: gradle/gradle-completion
branch: master
version: 25da917cf5a88f3e58f05be3868a7b2748c8afe6
precopy: |
set -e
find . ! -name _gradle ! -name LICENSE -delete
11 changes: 7 additions & 4 deletions .github/workflows/dependencies.yml
Expand Up @@ -8,19 +8,22 @@ jobs:
check:
name: Check for updates
runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
steps:
- name: Checkout
if: github.repository == 'ohmyzsh/ohmyzsh'
uses: actions/checkout@v4
- name: Authenticate as @ohmyzsh
id: generate_token
uses: ohmyzsh/github-app-token@v2
with:
app_id: ${{ secrets.OHMYZSH_APP_ID }}
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
- name: Process dependencies
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
TMP_DIR: ${{ env.RUNNER_TEMP }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
GIT_APP_NAME: ohmyzsh[bot]
GIT_APP_EMAIL: 54982679+ohmyzsh[bot]@users.noreply.github.com
TMP_DIR: ${{ runner.temp }}
run: |
gh auth login --with-token <<< "${GITHUB_TOKEN}"
pip install -r .github/workflows/dependencies/requirements.txt
python3 .github/workflows/dependencies/updater.py
2 changes: 2 additions & 0 deletions .github/workflows/dependencies/requirements.txt
@@ -0,0 +1,2 @@
PyYAML~=6.0.1
requests~=2.31.0
4 changes: 2 additions & 2 deletions .github/workflows/dependencies/updater.py
Expand Up @@ -302,8 +302,8 @@ def create_branch(path: str, version: str):

@staticmethod
def add_and_commit(scope: str, version: str):
user_name = "ohmyzsh"
user_email = "bot@ohmyz.sh"
user_name = os.environ.get("GIT_APP_NAME")
user_email = os.environ.get("GIT_APP_EMAIL")

# Add all files to git staging
CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles")
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/installer.yml
Expand Up @@ -26,7 +26,7 @@ jobs:
- macos-latest
steps:
- name: Set up git repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
Expand All @@ -42,7 +42,7 @@ jobs:
- test
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Vercel CLI
run: npm install -g vercel
- name: Setup project and deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -24,7 +24,7 @@ jobs:
if: github.repository == 'ohmyzsh/ohmyzsh'
steps:
- name: Set up git repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install zsh
run: sudo apt-get update; sudo apt-get install zsh
- name: Check syntax
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/project.yml
Expand Up @@ -15,9 +15,15 @@ jobs:
name: Add to project
runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
steps:
- name: Authenticate as @ohmyzsh
id: generate_token
uses: ohmyzsh/github-app-token@v2
with:
app_id: ${{ secrets.OHMYZSH_APP_ID }}
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
- name: Store app token
run: echo "GH_TOKEN=${{ steps.generate_token.outputs.token }}" >> "$GITHUB_ENV"
- name: Read project data
env:
ORGANIZATION: ohmyzsh
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -449,6 +449,10 @@ Oh My Zsh has a vibrant community of happy users and delightful contributors. Wi

Thank you so much!

<a href="https://github.com/ohmyzsh/ohmyzsh/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ohmyzsh/ohmyzsh" width="100%"/>
</a>

## Follow Us

We're on social media:
Expand Down
146 changes: 146 additions & 0 deletions lib/async_prompt.zsh
@@ -0,0 +1,146 @@
# The async code is taken from
# https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/async.zsh
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh

zmodload zsh/system

# For now, async prompt function handlers are set up like so:
# First, define the async function handler and register the handler
# with _omz_register_handler:
#
# function _git_prompt_status_async {
# # Do some expensive operation that outputs to stdout
# }
# _omz_register_handler _git_prompt_status_async
#
# Then add a stub prompt function in `$PROMPT` or similar prompt variables,
# which will show the output of "$_OMZ_ASYNC_OUTPUT[handler_name]":
#
# function git_prompt_status {
# echo -n $_OMZ_ASYNC_OUTPUT[_git_prompt_status_async]
# }
#
# RPROMPT='$(git_prompt_status)'
#
# This API is subject to change and optimization. Rely on it at your own risk.

function _omz_register_handler {
setopt localoptions noksharrays
typeset -ga _omz_async_functions
# we want to do nothing if there's no $1 function or we already set it up
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
|| (( ${_omz_async_functions[(Ie)$1]} )); then
return
fi
_omz_async_functions+=("$1")
# let's add the hook to async_request if it's not there yet
if (( ! ${precmd_functions[(Ie)_omz_async_request]} )) \
&& (( ${+functions[_omz_async_request]})); then
autoload -Uz add-zsh-hook
add-zsh-hook precmd _omz_async_request
fi
}

# Set up async handlers and callbacks
function _omz_async_request {
local -i ret=$?
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT

# executor runs a subshell for all async requests based on key
local handler
for handler in ${_omz_async_functions}; do
(( ${+functions[$handler]} )) || continue

local fd=${_OMZ_ASYNC_FDS[$handler]:--1}
local pid=${_OMZ_ASYNC_PIDS[$handler]:--1}

# If we've got a pending request, cancel it
if (( fd != -1 && pid != -1 )) && { true <&$fd } 2>/dev/null; then
# Close the file descriptor and remove the handler
exec {fd}<&-
zle -F $fd

# Zsh will make a new process group for the child process only if job
# control is enabled (MONITOR option)
if [[ -o MONITOR ]]; then
# Send the signal to the process group to kill any processes that may
# have been forked by the async function handler
kill -TERM -$pid 2>/dev/null
else
# Kill just the child process since it wasn't placed in a new process
# group. If the async function handler forked any child processes they may
# be orphaned and left behind.
kill -TERM $pid 2>/dev/null
fi
fi

# Define global variables to store the file descriptor, PID and output
_OMZ_ASYNC_FDS[$handler]=-1
_OMZ_ASYNC_PIDS[$handler]=-1

# Fork a process to fetch the git status and open a pipe to read from it
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)
# Run the async function handler
$handler
)

# Save FD for handler
_OMZ_ASYNC_FDS[$handler]=$fd

# 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

# Save the PID from the handler child process
read pid <&$fd
_OMZ_ASYNC_PIDS[$handler]=$pid

# When the fd is readable, call the response handler
zle -F "$fd" _omz_async_callback
done
}

# Called when new data is ready to be read from the pipe
function _omz_async_callback() {
emulate -L zsh

local fd=$1 # First arg will be fd ready for reading
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

# 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)"

# Repaint prompt if output has changed
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
zle reset-prompt
zle -R
fi

# Close the fd
exec {fd}<&-
fi

# Always remove the handler
zle -F "$fd"

# Unset global FD variable to prevent closing user created FDs in the precmd hook
_OMZ_ASYNC_FDS[$handler]=-1
_OMZ_ASYNC_PIDS[$handler]=-1
}

autoload -Uz add-zsh-hook
add-zsh-hook precmd _omz_async_request
2 changes: 1 addition & 1 deletion lib/cli.zsh
Expand Up @@ -448,7 +448,7 @@ function _omz::plugin::load {
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
_omz::log warn "'$plugin' is not a valid plugin"
continue
# It it is a valid plugin, add its directory to $fpath unless it is already there
# It is a valid plugin, add its directory to $fpath unless it is already there
elif (( ! ${fpath[(Ie)$base]} )); then
fpath=("$base" $fpath)
fi
Expand Down
2 changes: 1 addition & 1 deletion lib/clipboard.zsh
Expand Up @@ -62,7 +62,7 @@ function detect-clipboard() {
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
function clippaste() { wl-paste; }
function clippaste() { wl-paste --no-newline; }
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then
function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; }
function clippaste() { xsel --clipboard --output; }
Expand Down
2 changes: 1 addition & 1 deletion lib/completion.zsh
Expand Up @@ -49,7 +49,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
Expand Down

0 comments on commit 33425b6

Please sign in to comment.