From 799f9a8a8ae16e2b6a46dd3e9a9bd657bf614825 Mon Sep 17 00:00:00 2001 From: Ininsico <157946121+Ininsico@users.noreply.github.com> Date: Wed, 25 Nov 2026 10:22:08 +0500 Subject: [PATCH 01/40] fix(colorize): pass ZSH_COLORIZE_CHROMA_FORMATTER to cless (#13781) Closes #12650 --- plugins/colorize/colorize.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index c49acd864..68b620b82 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -90,6 +90,7 @@ colorize_less() { # (e.g. when not scrolled to the bottom) while already the next file will be displayed. local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \ ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \ + ZSH_COLORIZE_CHROMA_FORMATTER=$ZSH_COLORIZE_CHROMA_FORMATTER \ colorize_cat %s 2> /dev/null'" # LESSCLOSE will be set to prevent any errors by executing a user script From c8aea70a11a0acba1c7e0e8442eae024a6042eee Mon Sep 17 00:00:00 2001 From: mattmc3 Date: Wed, 25 Nov 2026 09:02:51 -0500 Subject: [PATCH 02/40] feat(zsh-patina): add completions (#14296) --- plugins/zsh-patina/README.md | 3 +++ plugins/zsh-patina/zsh-patina.plugin.zsh | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/plugins/zsh-patina/README.md b/plugins/zsh-patina/README.md index ec383323c..d23e79c64 100644 --- a/plugins/zsh-patina/README.md +++ b/plugins/zsh-patina/README.md @@ -4,6 +4,9 @@ Initializes [zsh-patina](https://github.com/michel-kraemer/zsh-patina), a "blazingly fast Zsh plugin performing syntax highlighting of your command line while you type 🌈" +The plugin also caches completions for the `zsh-patina` command in +`$ZSH_CACHE_DIR/completions/_zsh-patina`, refreshed each time the plugin loads. + To use it, add `zsh-patina` to the plugins array in your `.zshrc` file: ```zsh diff --git a/plugins/zsh-patina/zsh-patina.plugin.zsh b/plugins/zsh-patina/zsh-patina.plugin.zsh index bc6259ab1..6172f458b 100644 --- a/plugins/zsh-patina/zsh-patina.plugin.zsh +++ b/plugins/zsh-patina/zsh-patina.plugin.zsh @@ -2,6 +2,20 @@ if (( $+ZSH_HIGHLIGHT_VERSION )) || (( ${plugins[(Ie)zsh-syntax-highlighting]} ) echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them' elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)" + + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `zsh-patina`. Otherwise, compinit will have already done that. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_zsh-patina" ]]; then + typeset -g -A _comps + autoload -Uz _zsh-patina + _comps[zsh-patina]=_zsh-patina + fi + + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zsh-patina" + zf_mv -f -- =( "$1" completion ) "$ZSH_CACHE_DIR/completions/_zsh-patina" + } "${ZSH_PATINA_BINARY:-$commands[zsh-patina]}" &| else echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina' fi From ca5b808de89bec93697da5522923b4ce5aed6caf Mon Sep 17 00:00:00 2001 From: mattmc3 Date: Wed, 25 Nov 2026 09:11:57 -0500 Subject: [PATCH 03/40] feat(zsh-patina): add completions (#14296) From 1eebae3a3f2071b1502211547791e23495bbfb42 Mon Sep 17 00:00:00 2001 From: Ngonidzashe Mangudya <38191932+iamngoni@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:15:06 +0200 Subject: [PATCH 04/40] feat(laravel): add aliases for nWidart/laravel-modules (#14293) --- plugins/laravel/README.md | 14 ++++++++++++++ plugins/laravel/laravel.plugin.zsh | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/plugins/laravel/README.md b/plugins/laravel/README.md index fab9502d4..b790d2c81 100644 --- a/plugins/laravel/README.md +++ b/plugins/laravel/README.md @@ -80,3 +80,17 @@ zstyle ':omz:plugins:laravel' php 'herd php' | `paqr` | `php artisan queue:retry` | | `paqt` | `php artisan queue:table` | | `paqw` | `php artisan queue:work` | + +## Modules + +Aliases for [nWidart/laravel-modules](https://github.com/nWidart/laravel-modules). + +| Alias | Description | +|:-:|:-:| +| `pamol` | `php artisan module:list` | +| `pamomk` | `php artisan module:make` | +| `pamoe` | `php artisan module:enable` | +| `pamod` | `php artisan module:disable` | +| `pamom` | `php artisan module:migrate` | +| `pamomr` | `php artisan module:migrate-rollback` | +| `pamos` | `php artisan module:seed` | diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh index 17b2d2825..798d81d02 100644 --- a/plugins/laravel/laravel.plugin.zsh +++ b/plugins/laravel/laravel.plugin.zsh @@ -53,4 +53,13 @@ alias paqr="$_omz_laravel_php artisan queue:retry" alias paqt="$_omz_laravel_php artisan queue:table" alias paqw="$_omz_laravel_php artisan queue:work" +# Modules (nWidart/laravel-modules) +alias pamol="$_omz_laravel_php artisan module:list" +alias pamomk="$_omz_laravel_php artisan module:make" +alias pamoe="$_omz_laravel_php artisan module:enable" +alias pamod="$_omz_laravel_php artisan module:disable" +alias pamom="$_omz_laravel_php artisan module:migrate" +alias pamomr="$_omz_laravel_php artisan module:migrate-rollback" +alias pamos="$_omz_laravel_php artisan module:seed" + unset _omz_laravel_php From 964e5b65c6290fc52367cc49a7c1513d49efd3ff Mon Sep 17 00:00:00 2001 From: Morningstar202604 <320475654+Morningstar202604@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:45:29 +0800 Subject: [PATCH 05/40] fix(vi-mode): fix stale clipboard retry after failed push (#14141) --- plugins/vi-mode/README.md | 9 ++++++++ plugins/vi-mode/vi-mode.plugin.zsh | 33 ++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index bc78cfa3d..16135223c 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -39,6 +39,15 @@ plugins=(... vi-mode) - `VI_MODE_DISABLE_CLIPBOARD`: If set, disables clipboard integration on yank/paste +Clipboard integration keeps put widgets (`p`/`P`) in sync with the system +clipboard, but only while the last copy to the clipboard actually succeeded. +If that copy failed — no `xclip`/`xsel`, Wayland without `wl-clipboard`, a dead +X forwarding over SSH — the clipboard no longer mirrors what you killed inside +the line editor, so puts use the internal kill buffer instead of the stale +clipboard contents. After a failed push, puts keep using the kill buffer only +while the clipboard still holds exactly what it held when the push failed; a +new external copy is picked up again immediately. + ## Mode indicators *Normal mode* is indicated with a red `<<<` mark at the right prompt, when it diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 2704fb05e..7c057b788 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -118,6 +118,15 @@ bindkey '^s' history-incremental-search-forward bindkey '^a' beginning-of-line bindkey '^e' end-of-line +# Snapshot of the clipboard taken when the most recent push to it failed. +# While the marker is set, put widgets compare the live clipboard against the +# snapshot: unchanged means the clipboard is stale (it never received the +# kill), so the internal CUTBUFFER is used instead. As soon as the clipboard +# differs again - e.g. an external copy - it is trusted immediately, so +# external copies are never lost for longer than the failure itself. +typeset -g _OMZ_VI_CLIPBOARD_STALE="" +typeset -g _OMZ_VI_CLIPBOARD_STALE_SET="" + function wrap_clipboard_widgets() { # NB: Assume we are the first wrapper and that we only wrap native widgets # See zsh-autosuggestions.zsh for a more generic and more robust wrapper @@ -132,13 +141,33 @@ function wrap_clipboard_widgets() { eval " function ${wrapped_name}() { zle .${widget} - printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null || true + # On a failed push, snapshot the clipboard so put widgets can tell + # stale content (which never received this kill) apart from later + # external copies. + if printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null; then + _OMZ_VI_CLIPBOARD_STALE_SET=\"\" + else + _OMZ_VI_CLIPBOARD_STALE=\"\$(clippaste 2>/dev/null)\" + _OMZ_VI_CLIPBOARD_STALE_SET=1 + fi } " else eval " function ${wrapped_name}() { - CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\" + if [[ -n \"\${_OMZ_VI_CLIPBOARD_STALE_SET:-}\" ]]; then + # Last push failed. If the clipboard still matches the snapshot + # taken at the failure, it is stale: keep the internal CUTBUFFER. + # If it differs, an external copy arrived since - trust it again + # and clear the stale state. + local _clip=\"\$(clippaste 2>/dev/null)\" + if [[ \"\$_clip\" != \"\${_OMZ_VI_CLIPBOARD_STALE}\" ]]; then + CUTBUFFER=\"\$_clip\" + _OMZ_VI_CLIPBOARD_STALE_SET=\"\" + fi + else + CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\" + fi zle .${widget} } " From ad66117d082e02a8b5515f20af71d934d04d323f Mon Sep 17 00:00:00 2001 From: Jonathan Stacks Date: Thu, 26 Nov 2026 08:50:09 -0600 Subject: [PATCH 06/40] feat(talosctl): add completions for talosctl (#13682) --- plugins/talosctl/README.md | 20 ++++++++++++++++++++ plugins/talosctl/talosctl.plugin.zsh | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 plugins/talosctl/README.md create mode 100644 plugins/talosctl/talosctl.plugin.zsh diff --git a/plugins/talosctl/README.md b/plugins/talosctl/README.md new file mode 100644 index 000000000..750104e10 --- /dev/null +++ b/plugins/talosctl/README.md @@ -0,0 +1,20 @@ +# talosctl plugin + +This plugin adds completion for the [talosctl](https://docs.siderolabs.com/talos/v1.12/learn-more/talosctl) CLI for managing [Talos](https://github.com/siderolabs/talos) Linux. + +To use it, add `talosctl` to the plugins array in your zshrc file: + +```zsh +plugins=(... talosctl) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and is automatically updated asynchronously when the plugin is +loaded, which is usually when you start up a new terminal emulator. + +The cache is stored at: + +- `$ZSH_CACHE/completions/_talosctl` completions script diff --git a/plugins/talosctl/talosctl.plugin.zsh b/plugins/talosctl/talosctl.plugin.zsh new file mode 100644 index 000000000..0ff41d819 --- /dev/null +++ b/plugins/talosctl/talosctl.plugin.zsh @@ -0,0 +1,18 @@ +# Autocompletion for talosctl +if (( ! $+commands[talosctl] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `talosctl`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_talosctl" ]]; then + typeset -g -A _comps + autoload -Uz _talosctl + _comps[talosctl]=_talosctl +fi + +zmodload -F zsh/files b:zf_mv +() { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._talosctl" + zf_mv -f -- =( talosctl completion zsh ) "$ZSH_CACHE_DIR/completions/_talosctl" +} &| From 1a05a1091be6bda0158aa24cdc9bdb881f1fc60c Mon Sep 17 00:00:00 2001 From: Thejesh Date: Thu, 26 Nov 2026 06:51:15 -0800 Subject: [PATCH 07/40] fix(cli): add plugins to an empty plugins=() list (#14276) --- lib/cli.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index a28facb1d..59873368b 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -392,8 +392,8 @@ function _omz::plugin::enable { # Enable plugins awk script local awk_script=" -# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line -/^[ \t]*plugins=\([^#]+\).*\$/ { +# if plugins=() is in oneline form (empty or not), substitute ) with new plugins and go to the next line +/^[ \t]*plugins=\([^#]*\).*\$/ { sub(/\)/, \" $add_plugins&\") print \$0 next From 4d643a3c8673793d1155a47abc0382fa775f2c72 Mon Sep 17 00:00:00 2001 From: Thejesh Date: Thu, 26 Nov 2026 07:20:09 -0800 Subject: [PATCH 08/40] fix(web-search): escape reserved characters like + and & (#14275) --- plugins/web-search/web-search.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 9f0b913b8..e907636f6 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -53,10 +53,11 @@ function web_search() { # search or go to main page depending on number of arguments passed if [[ $# -gt 1 ]]; then - # if search goes in the query string ==> space as +, otherwise %20 + # if search goes in the query string ==> space as + and escape reserved + # characters like & and +, otherwise %20 # see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20 local param="-P" - [[ "$urls[$1]" == *\?*= ]] && param="" + [[ "$urls[$1]" == *\?*= ]] && param="-r" # build search url: # join arguments passed with '+', then append to search engine URL From 0876f102648b5b8fb273b34f7bce9b24b25417fc Mon Sep 17 00:00:00 2001 From: Randommisha13 <52196819+Randommisha13@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:20:17 +0500 Subject: [PATCH 09/40] feat(systemd): support other privilege elevation tools (#13695) --- plugins/systemd/README.md | 24 +++++++++++++++++++++++- plugins/systemd/systemd.plugin.zsh | 21 ++++++++++++++++----- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/plugins/systemd/README.md b/plugins/systemd/README.md index 1980ae373..7566e5cf0 100644 --- a/plugins/systemd/README.md +++ b/plugins/systemd/README.md @@ -24,7 +24,7 @@ plugins=(... systemd) | `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block | | `sc-cat` | `systemctl cat` | Show backing files of one or more units | | `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory | -| **Aliases with sudo** ||| +| **Privileged aliases** ||| | `sc-start` | `sudo systemctl start` | Start Unit(s) | | `sc-stop` | `sudo systemctl stop` | Stop Unit(s) | | `sc-reload` | `sudo systemctl reload` | Reload Unit(s) | @@ -50,6 +50,28 @@ plugins=(... systemd) | `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) | | `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) | +### Privileged aliases + +systemd plugin supports alternative privilege elevation tools. You can prepend an arbitrary string, +replacing `sudo`, to the privileged aliases by setting `$ZSH_SYSTEMD_SUDO` variable. You can leave +authorization to systemd by setting `$ZSH_SYSTEMD_SUDO` to an empty string. + +To use `doas` as your elevation tool you will need to add the following line to your zshrc; + +```zsh +ZSH_SYSTEMD_SUDO="doas" +``` + +After shell restart, you will see that alias for `sc-enable` is changed: + +```sh +$ which sc-enable +sc-enable: aliased to doas systemctl enable +``` + +These aliases are evaluated during oh-my-zsh startup, and can't be changed interactively (you will +need to restart shell to see changes). + ### User aliases You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`. diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 842174df0..59469e75e 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -67,15 +67,27 @@ power_commands=( suspend ) +if ! [[ -v ZSH_SYSTEMD_SUDO ]]; then + ZSH_SYSTEMD_SUDO="sudo" +fi + for c in $user_commands; do alias "sc-$c"="systemctl $c" alias "scu-$c"="systemctl --user $c" done -for c in $sudo_commands; do - alias "sc-$c"="sudo systemctl $c" - alias "scu-$c"="systemctl --user $c" -done +# Avoids leading space in alias when using polkit +if [[ -n "${ZSH_SYSTEMD_SUDO}" ]]; then + for c in $sudo_commands; do + alias "sc-$c"="$ZSH_SYSTEMD_SUDO systemctl $c" + alias "scu-$c"="systemctl --user $c" + done +else + for c in $sudo_commands; do + alias "sc-$c"="systemctl $c" + alias "scu-$c"="systemctl --user $c" + done +fi for c in $power_commands; do alias "sc-$c"="systemctl $c" @@ -83,7 +95,6 @@ done unset c user_commands sudo_commands power_commands - # --now commands alias sc-enable-now="sc-enable --now" alias sc-disable-now="sc-disable --now" From f5a74e0347c908214a5343427accf796e1cc7149 Mon Sep 17 00:00:00 2001 From: Kennan LeJeune Date: Thu, 26 Nov 2026 10:20:27 -0500 Subject: [PATCH 10/40] feat(fnox): add plugin (#13593) --- plugins/fnox/README.md | 15 +++++++++++++++ plugins/fnox/fnox.plugin.zsh | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 plugins/fnox/README.md create mode 100644 plugins/fnox/fnox.plugin.zsh diff --git a/plugins/fnox/README.md b/plugins/fnox/README.md new file mode 100644 index 000000000..4f0a69369 --- /dev/null +++ b/plugins/fnox/README.md @@ -0,0 +1,15 @@ +# fnox + +Adds shell integration and completions for [fnox](https://github.com/jdx/fnox), a tool for provider-agnostic secret injection. + +## Installation + +[Install fnox](https://fnox.jdx.dev/guide/quick-start.html), then add it to your plugins in `~/.zshrc`: + +```zsh +plugins=(fnox) +``` + +## Usage + +See the [fnox documentation](https://fnox.jdx.dev/guide/shell-integration.html) for shell integration and usage. diff --git a/plugins/fnox/fnox.plugin.zsh b/plugins/fnox/fnox.plugin.zsh new file mode 100644 index 000000000..d2e924695 --- /dev/null +++ b/plugins/fnox/fnox.plugin.zsh @@ -0,0 +1,23 @@ +if (( ! $+commands[fnox] )); then + # if we don't have fnox at all just bail out + return +fi + +eval "$(fnox activate zsh)" + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `fnox`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnox" ]]; then + typeset -g -A _comps + autoload -Uz _fnox + _comps[fnox]=_fnox +fi + +# Regenerate completions when the executable changes. +if [[ ! -s "$ZSH_CACHE_DIR/completions/_fnox" || "$commands[fnox]" -nt "$ZSH_CACHE_DIR/completions/_fnox" ]]; then + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnox" + zf_mv -f -- =( fnox completion zsh ) "$ZSH_CACHE_DIR/completions/_fnox" + } &| +fi From 12a6ce7e42f1c05001c42190bad95410fe64104f Mon Sep 17 00:00:00 2001 From: kang Date: Thu, 26 Nov 2026 23:20:36 +0800 Subject: [PATCH 11/40] feat(python): add recursive parent directory search for auto_vrun (#13523) --- plugins/python/README.md | 2 ++ plugins/python/python.plugin.zsh | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/python/README.md b/plugins/python/README.md index ca424ea55..beab84a01 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -34,6 +34,8 @@ virtual environments: `/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated in subdirectories). - To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh. + - To also search parent directories (useful for monorepos), set `PYTHON_AUTO_VRUN_RECURSIVE=true` as well. + The search stops before `$HOME`, so a venv in your home directory is not activated in every folder under it. - The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`. The default virtual environment name is `venv`. To use a different name, set `PYTHON_VENV_NAME=`. For example: `PYTHON_VENV_NAME=".venv"` diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index e96363b9b..562b19e78 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -113,8 +113,23 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then # make sure we're not in a venv already (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 source $file > /dev/null 2>&1 - break + return done + + # Search parent directories if recursive mode is enabled, stopping before $HOME + if [[ "$PYTHON_AUTO_VRUN_RECURSIVE" == "true" ]]; then + local search_dir="$PWD:h" + while [[ "$search_dir" != "/" && "$search_dir" != "." && "$search_dir" != "$HOME" ]]; do + for file in "${search_dir}/"${^PYTHON_VENV_NAMES[@]}"/bin/activate"(N.); do + # the venv found is already active + [[ "${file:h:h:A}" == "${VIRTUAL_ENV:A}" ]] && return + (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 + source $file > /dev/null 2>&1 + return + done + search_dir="${search_dir:h}" + done + fi fi } add-zsh-hook chpwd auto_vrun From b1d468701a6ce2f794be271c56ba2364392527a3 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 27 Nov 2026 00:28:45 +0900 Subject: [PATCH 12/40] fix(git): remove unnecessary git rm from gwip (#13410) --- plugins/git/README.md | 2 +- plugins/git/git.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index b5732aebc..4ac7edb42 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -21,7 +21,7 @@ plugins=(... git) | `gapa` | `git add --patch` | | `gau` | `git add --update` | | `gav` | `git add --verbose` | -| `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` | +| `gwip` | `git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` | | `gam` | `git am` | | `gama` | `git am --abort` | | `gamc` | `git am --continue` | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index c16ae777e..e0cbd45af 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -119,7 +119,7 @@ alias gaa='git add --all' alias gapa='git add --patch' alias gau='git add --update' alias gav='git add --verbose' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' +alias gwip='git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' alias gam='git am' alias gama='git am --abort' alias gamc='git am --continue' From e333686c2ad3cba53625b35b361a00cadb281712 Mon Sep 17 00:00:00 2001 From: Federico Tensi Date: Thu, 26 Nov 2026 16:28:56 +0100 Subject: [PATCH 13/40] feat(git-commit): support optional commit body (#14169) --- plugins/git-commit/README.md | 8 ++++++-- plugins/git-commit/git-commands/omz_git_commit | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/git-commit/README.md b/plugins/git-commit/README.md index ca3aed21b..79ff4fb3d 100644 --- a/plugins/git-commit/README.md +++ b/plugins/git-commit/README.md @@ -12,7 +12,7 @@ plugins=(... git-commit) ## Syntax ```zsh -git [(-s, --scope) ""] [(-a, --attention)] "" +git [(-s, --scope) ""] [(-a, --attention)] [(-b, --body) ""] "" ``` Where `type` is one of the following: @@ -30,6 +30,9 @@ Where `type` is one of the following: - `test` - `wip` +The optional `-b` / `--body` becomes the commit body (a blank line after the subject), as defined by +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary). + > NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the > git command of the same name. It will still generate a commit message in the format > `revert: ` @@ -39,6 +42,7 @@ Where `type` is one of the following: | Git subcommand | Command | | --------------------------------------------- | ---------------------------------------------------- | | `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` | -| `git wip "work in progress"` | `git commit -m "work in progress"` | +| `git wip "work in progress"` | `git commit -m "wip: work in progress"` | | `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` | | `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` | +| `git feat -s "auth" -b "Keep session across redirects." "add login redirect"` | `git commit -m "feat(auth): add login redirect" -m "Keep session across redirects."` | diff --git a/plugins/git-commit/git-commands/omz_git_commit b/plugins/git-commit/git-commands/omz_git_commit index c493e6198..8555100b7 100755 --- a/plugins/git-commit/git-commands/omz_git_commit +++ b/plugins/git-commit/git-commands/omz_git_commit @@ -12,11 +12,11 @@ _omz_git_commit() { if [[ "$_type" == rev ]]; then _type=revert fi - local _scope _attention _message + local _scope _attention _message _body while [ $# -ne 0 ]; do case $1 in -s | --scope ) - if [ -z $2 ]; then + if [ -z "$2" ]; then echo >&2 "Missing scope!" return 1 fi @@ -27,12 +27,20 @@ _omz_git_commit() { _attention="!" shift 1 ;; + -b | --body ) + if [ -z "$2" ]; then + echo >&2 "Missing body!" + return 1 + fi + _body="$2" + shift 2 + ;; * ) _message="${_message} $1" shift 1 ;; esac done - git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" + git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"} } _omz_git_commit "$@" From 070831e592ee3b325c3d86eec71fc57cbb5ce0e5 Mon Sep 17 00:00:00 2001 From: Shahab Ahmed Date: Thu, 26 Nov 2026 20:29:06 +0500 Subject: [PATCH 14/40] fix(extract): extract .deb members without double nesting (#14199) Closes #14200 --- plugins/extract/extract.plugin.zsh | 37 +++++++- plugins/extract/tests/extract.test.zsh | 121 ++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 4 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index e832ee443..bd8e73d6e 100755 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -135,9 +135,40 @@ EOF (*.deb) command mkdir -p "control" "data" ar vx "$full_path" > /dev/null - builtin cd -q control; extract ../control.tar.* - builtin cd -q ../data; extract ../data.tar.* - builtin cd -q ..; command rm *.tar.* debian-binary ;; + local member= dest= failed=0 + for member in control.tar.* data.tar.*; do + dest="${member%%.*}" + case "${member:l}" in + (*.tar.gz) + (( $+commands[pigz] )) && { tar -I pigz -xvf "$member" -C "$dest" } \ + || tar zxvf "$member" -C "$dest" ;; + (*.tar.bz2) + (( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$member" -C "$dest" } \ + || tar xvjf "$member" -C "$dest" ;; + (*.tar.xz) + # .deb members are small, so skip extract()'s pixz fast path and + # let tar use its built-in xz support (or a plain pipe). + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$member" -C "$dest" \ + || xzcat "$member" | tar xvf - -C "$dest" ;; + (*.tar.zst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$member" -C "$dest" \ + || zstdcat "$member" | tar xvf - -C "$dest" ;; + (*.tar) + tar xvf "$member" -C "$dest" ;; + (*) + echo "extract: cannot extract unexpected .deb member '$member'" >&2 + failed=1 + success=1 ;; + esac + done + if (( failed )); then + # Keep the archive members so the unexpected one can be inspected. + echo "extract: leaving .deb members in place" >&2 + else + command rm *.tar.* debian-binary + fi ;; (*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;; (*.cab|*.exe) cabextract "$full_path" ;; (*.cpio|*.obscpio) cpio -idmvF "$full_path" ;; diff --git a/plugins/extract/tests/extract.test.zsh b/plugins/extract/tests/extract.test.zsh index fe32f978a..180fce046 100644 --- a/plugins/extract/tests/extract.test.zsh +++ b/plugins/extract/tests/extract.test.zsh @@ -4,7 +4,7 @@ emulate -L zsh setopt err_return -for tool in lzma unlzma uncompress; do +for tool in ar lzma unlzma uncompress; do (( $+commands[$tool] )) || { print -u2 -r -- "These tests require $tool." exit 1 @@ -46,6 +46,120 @@ check_extract() { print -r -- "PASS: $extension ($mode)" } +# Extracting a .deb must place the control members directly in /control +# and the data members directly in /data, whatever their member count. +check_deb_extract() { + local mode=$1 + local case_dir="$test_dir/deb-$mode" + mkdir -p "$case_dir/source files" "$case_dir/work/target dir" \ + "$case_dir/src/ctl" "$case_dir/src/data/usr/bin" + print -r -- "postinst script" > "$case_dir/src/ctl/postinst" + print -r -- "conf:1" > "$case_dir/src/ctl/conffiles" + print -r -- "app main" > "$case_dir/src/data/usr/bin/app" + tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" conffiles postinst + tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr + print -r -- "2.0" > "$case_dir/src/debian-binary" + ( + builtin cd "$case_dir/src" + rm -f "$case_dir/source files/pkg.deb" + ar rS "$case_dir/source files/pkg.deb" debian-binary control.tar.gz data.tar.gz + ) + local archive="$case_dir/source files/pkg.deb" + + builtin cd "$case_dir/work" + local base="$PWD/pkg" + local -a args + case "$mode" in + target) + args=(-t 'target dir') + base="$PWD/target dir/pkg" + ;; + remove) args=(-r) ;; + esac + + () { + emulate -L zsh + extract "${args[@]}" "$archive" + } || return 1 + + [[ -f "$base/control/conffiles" && -f "$base/control/postinst" ]] || + { print -u2 -r -- "$mode: control members not extracted into $base/control"; return 1 } + [[ -f "$base/data/usr/bin/app" ]] || + { print -u2 -r -- "$mode: data members not extracted into $base/data"; return 1 } + [[ ! -d "$base/control/control" && ! -d "$base/data/data" ]] || + { print -u2 -r -- "$mode: deb extraction double-nested the member directories"; return 1 } + [[ ! -e "$base/control.tar.gz" && ! -e "$base/data.tar.gz" && ! -e "$base/debian-binary" ]] || + { print -u2 -r -- "$mode: deb member debris left behind"; return 1 } + if [[ $mode == remove ]]; then + [[ ! -e $archive ]] + else + [[ -f $archive ]] + fi + print -r -- "PASS: deb ($mode)" +} + +# An unexpected member must be reported and left on disk for inspection, and +# the cleanup must not delete the other members around it either. +check_deb_unexpected_member() { + local case_dir="$test_dir/deb-unexpected" + mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin" + print -r -- "postinst script" > "$case_dir/src/ctl/postinst" + print -r -- "app main" > "$case_dir/src/data/usr/bin/app" + tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst + print -r -- "unknown compression" > "$case_dir/src/control.tar.weird" + tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr + print -r -- "2.0" > "$case_dir/src/debian-binary" + ( + builtin cd "$case_dir/src" + ar rS "$case_dir/pkg.deb" debian-binary control.tar.weird data.tar.gz + ) + + builtin cd "$case_dir" + () { + emulate -L zsh + extract "$case_dir/pkg.deb" + } || return 1 + + [[ -f "$case_dir/pkg/data/usr/bin/app" ]] || + { print -u2 -r -- "deb-unexpected: known members were not extracted"; return 1 } + [[ -f "$case_dir/pkg/control.tar.weird" && -f "$case_dir/pkg/data.tar.gz" && + -f "$case_dir/pkg/debian-binary" ]] || + { print -u2 -r -- "deb-unexpected: archive members were deleted"; return 1 } + print -r -- "PASS: deb (unexpected member)" +} + +# Passing more than one .deb in a single call must not leak the loop variables +# between archives; the stale `member`/`dest` locals used to be printed by the +# second archive. +check_deb_multiple() { + local case_dir="$test_dir/deb-multiple" + mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin" + print -r -- "postinst script" > "$case_dir/src/ctl/postinst" + print -r -- "app main" > "$case_dir/src/data/usr/bin/app" + tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst + tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr + print -r -- "2.0" > "$case_dir/src/debian-binary" + ( + builtin cd "$case_dir/src" + ar rS "$case_dir/one.deb" debian-binary control.tar.gz data.tar.gz + ar rS "$case_dir/two.deb" debian-binary control.tar.gz data.tar.gz + ) + + builtin cd "$case_dir" + local output + output=$( () { + emulate -L zsh + extract one.deb two.deb + } 2>&1 ) || return 1 + + [[ $output != *member=* && $output != *dest=* ]] || + { print -u2 -r -- "deb-multiple: stale loop variables were printed"; return 1 } + [[ -f one/control/postinst && -f one/data/usr/bin/app && + -f two/control/postinst && -f two/data/usr/bin/app ]] || + { print -u2 -r -- "deb-multiple: both archives were not extracted"; return 1 } + print -r -- "PASS: deb (multiple archives)" +} + { print -r -- hello > "$test_dir/plain" lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma" @@ -58,6 +172,11 @@ check_extract() { check_extract "$extension" "$mode" done done + check_deb_extract default + check_deb_extract target + check_deb_extract remove + check_deb_unexpected_member + check_deb_multiple print 'All extract compressed-file tests passed.' } always { builtin cd "$original_dir" From abfce729ab56543b976b08ef34a54b3dc57601a4 Mon Sep 17 00:00:00 2001 From: Jim Weller <31997291+jimweller@users.noreply.github.com> Date: Thu, 26 Nov 2026 07:29:16 -0800 Subject: [PATCH 15/40] feat(terragrunt): add terragrunt plugin (#13261) --- plugins/terragrunt/README.md | 53 ++++++++++++++++++++++++ plugins/terragrunt/terragrunt.plugin.zsh | 27 ++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 plugins/terragrunt/README.md create mode 100644 plugins/terragrunt/terragrunt.plugin.zsh diff --git a/plugins/terragrunt/README.md b/plugins/terragrunt/README.md new file mode 100644 index 000000000..d2b5d8809 --- /dev/null +++ b/plugins/terragrunt/README.md @@ -0,0 +1,53 @@ +# Terragrunt plugin + +Terragrunt is a thin wrapper for opentofu/terraform that provides extra tools +and features to enhance the management of Infrastructure as Code (IaC) using +opentofu/terraform. This plugin adds completion for `terragrunt` command, as well +as aliases and a prompt function. + +To use it, add `terragrunt` to the plugins array of your `~/.zshrc` file: + +```shell +plugins=(... terragrunt) +``` + +## Requirements + +- [Terragrunt](https://docs.terragrunt.com/) v0.77.22 or later + +## Aliases + +| Alias | Command | +| ------ | ----------------------------------------- | +| `tg` | `terragrunt` | +| `tga` | `terragrunt run -- apply` | +| `tgaa` | `terragrunt run -- apply -auto-approve` | +| `tgc` | `terragrunt run -- console` | +| `tgd` | `terragrunt run -- destroy` | +| `tgd!` | `terragrunt run -- destroy -auto-approve` | +| `tgi` | `terragrunt run -- init` | +| `tgo` | `terragrunt run -- output` | +| `tgp` | `terragrunt run -- plan` | +| `tgv` | `terragrunt run -- validate` | +| `tgs` | `terragrunt run -- state` | +| `tgsh` | `terragrunt run -- show` | +| `tgr` | `terragrunt run -- refresh` | +| `tgt` | `terragrunt run -- test` | +| `tgws` | `terragrunt run -- workspace` | + +## Prompt function + +- `terragrunt_version_prompt_info` shows the current version of the `terragrunt` command. + +To use it, add it to a `PROMPT` or `RPROMPT` variable in your theme or `.zshrc` file. + +```sh +RPROMPT='$(terragrunt_version_prompt_info)' +``` + +You can also specify the PREFIX and SUFFIX strings with the following variables. + +```sh +ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX="%{$fg[white]%}" +ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX="%{$reset_color%}" +``` diff --git a/plugins/terragrunt/terragrunt.plugin.zsh b/plugins/terragrunt/terragrunt.plugin.zsh new file mode 100644 index 000000000..c2c71425e --- /dev/null +++ b/plugins/terragrunt/terragrunt.plugin.zsh @@ -0,0 +1,27 @@ +# set up the terragrunt completion (compatible for zsh) +autoload -Uz bashcompinit && bashcompinit +complete -C terragrunt terragrunt + +# terragrunt version prompt function +function terragrunt_version_prompt_info() { + # get the output of `terragrunt --version` in a single line, and get the third word after splitting by a space + local terragrunt_version=${${(s: :)$(terragrunt --version)}[3]} + # make sure to escape % signs in the version string to prevent command injection + echo "${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX-[}${terragrunt_version:gs/%/%%}${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX-]}" +} + +alias tg='terragrunt' +alias tga='terragrunt run -- apply' +alias tgaa='terragrunt run -- apply -auto-approve' +alias tgc='terragrunt run -- console' +alias tgd='terragrunt run -- destroy' +alias tgd!='terragrunt run -- destroy -auto-approve' +alias tgi='terragrunt run -- init' +alias tgo='terragrunt run -- output' +alias tgp='terragrunt run -- plan' +alias tgv='terragrunt run -- validate' +alias tgs='terragrunt run -- state' +alias tgsh='terragrunt run -- show' +alias tgr='terragrunt run -- refresh' +alias tgt='terragrunt run -- test' +alias tgws='terragrunt run -- workspace' From 53f0790157d1550feccb60febe140565c8c9f25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=EC=98=81?= Date: Sat, 28 Nov 2026 06:22:57 +0900 Subject: [PATCH 16/40] feat(git): add `gsms` alias for `git submodule status` (#13586) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 4ac7edb42..3b0f3f3b7 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -208,6 +208,7 @@ plugins=(... git) | `gsb` | `git status --short -b` | | `gsnut` | `git status --untracked-files=no` | | `gsi` | `git submodule init` | +| `gsms` | `git submodule status` | | `gsu` | `git submodule update` | | `gsuri` | `git submodule update --recursive --init` | | `gsd` | `git svn dcommit` | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index e0cbd45af..a2bb94993 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -410,6 +410,7 @@ alias gss='git status --short' alias gsb='git status --short --branch' alias gsnut='git status --untracked-files=no' alias gsi='git submodule init' +alias gsms='git submodule status' alias gsu='git submodule update' alias gsuri='git submodule update --recursive --init' alias gsd='git svn dcommit' From 924db8c81b989dc9ec7b973c291e1a7ea2a40544 Mon Sep 17 00:00:00 2001 From: Alexander Schaber <129312+aschaber1@users.noreply.github.com> Date: Fri, 27 Nov 2026 22:23:29 +0100 Subject: [PATCH 17/40] refactor(plugins): use cached background completion generation (#13662) Move invoke, istioctl, kn, kompose, kops, oc, operator-sdk, please and svcat off sourcing `<($cmd completion ...)` on every startup. The completion script is now cached under $ZSH_CACHE_DIR/completions and regenerated in the background, following the pattern used by the helm plugin. Writes go through a temp file (prefixed with a dot to keep it out of $fpath) that is moved into place atomically with `zf_mv`, so a half-written file is never sourced. --- plugins/invoke/invoke.plugin.zsh | 21 ++++++++++++++++---- plugins/istioctl/istioctl.plugin.zsh | 20 ++++++++++++++++--- plugins/kn/kn.plugin.zsh | 21 ++++++++++++++++---- plugins/kompose/kompose.plugin.zsh | 19 ++++++++++++++++-- plugins/kops/kops.plugin.zsh | 19 ++++++++++++++++-- plugins/oc/oc.plugin.zsh | 19 +++++++++++++++--- plugins/operator-sdk/operator-sdk.plugin.zsh | 20 ++++++++++++++++--- plugins/please/please.plugin.zsh | 19 ++++++++++++++++-- plugins/svcat/svcat.plugin.zsh | 20 +++++++++++++++---- 9 files changed, 151 insertions(+), 27 deletions(-) diff --git a/plugins/invoke/invoke.plugin.zsh b/plugins/invoke/invoke.plugin.zsh index 8c807de02..4e8849a15 100644 --- a/plugins/invoke/invoke.plugin.zsh +++ b/plugins/invoke/invoke.plugin.zsh @@ -1,5 +1,18 @@ -# Autocompletion for invoke. -# -if [ $commands[invoke] ]; then - source <(invoke --print-completion-script=zsh) +# Autocompletion for the Invoke CLI (invoke). +if (( ! $+commands[invoke] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_invoke" ]]; then + invoke --print-completion-script=zsh | tee "$ZSH_CACHE_DIR/completions/_invoke" >/dev/null + source "$ZSH_CACHE_DIR/completions/_invoke" +else + source "$ZSH_CACHE_DIR/completions/_invoke" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._invoke" + zf_mv -f -- =( invoke --print-completion-script=zsh ) "$ZSH_CACHE_DIR/completions/_invoke" + } &| fi diff --git a/plugins/istioctl/istioctl.plugin.zsh b/plugins/istioctl/istioctl.plugin.zsh index 13ead1b2b..8c9698e87 100644 --- a/plugins/istioctl/istioctl.plugin.zsh +++ b/plugins/istioctl/istioctl.plugin.zsh @@ -1,4 +1,18 @@ -if [ $commands[istioctl] ]; then - source <(istioctl completion zsh) - compdef _istioctl istioctl +# Autocompletion for the Istio CLI (istioctl). +if (( ! $+commands[istioctl] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_istioctl" ]]; then + istioctl completion zsh | tee "$ZSH_CACHE_DIR/completions/_istioctl" >/dev/null + source "$ZSH_CACHE_DIR/completions/_istioctl" +else + source "$ZSH_CACHE_DIR/completions/_istioctl" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._istioctl" + zf_mv -f -- =( istioctl completion zsh ) "$ZSH_CACHE_DIR/completions/_istioctl" + } &| fi diff --git a/plugins/kn/kn.plugin.zsh b/plugins/kn/kn.plugin.zsh index 483d1d68c..028b2bfa9 100644 --- a/plugins/kn/kn.plugin.zsh +++ b/plugins/kn/kn.plugin.zsh @@ -1,8 +1,21 @@ -# Autocompletion for kn, the command line interface for knative +# Autocompletion for kn, the command line interface for Knative. # # Author: https://github.com/btannous -if [ $commands[kn] ]; then - source <(kn completion zsh) - compdef _kn kn +if (( ! $+commands[kn] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_kn" ]]; then + kn completion zsh | tee "$ZSH_CACHE_DIR/completions/_kn" >/dev/null + source "$ZSH_CACHE_DIR/completions/_kn" +else + source "$ZSH_CACHE_DIR/completions/_kn" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kn" + zf_mv -f -- =( kn completion zsh ) "$ZSH_CACHE_DIR/completions/_kn" + } &| fi diff --git a/plugins/kompose/kompose.plugin.zsh b/plugins/kompose/kompose.plugin.zsh index 764e724e6..72ab8c47c 100644 --- a/plugins/kompose/kompose.plugin.zsh +++ b/plugins/kompose/kompose.plugin.zsh @@ -1,3 +1,18 @@ -if [ $commands[kompose] ]; then - source <(kompose completion zsh) +# Autocompletion for the Kompose CLI (kompose). +if (( ! $+commands[kompose] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_kompose" ]]; then + kompose completion zsh | tee "$ZSH_CACHE_DIR/completions/_kompose" >/dev/null + source "$ZSH_CACHE_DIR/completions/_kompose" +else + source "$ZSH_CACHE_DIR/completions/_kompose" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kompose" + zf_mv -f -- =( kompose completion zsh ) "$ZSH_CACHE_DIR/completions/_kompose" + } &| fi diff --git a/plugins/kops/kops.plugin.zsh b/plugins/kops/kops.plugin.zsh index 0c38ce2df..30b1f22df 100644 --- a/plugins/kops/kops.plugin.zsh +++ b/plugins/kops/kops.plugin.zsh @@ -1,3 +1,18 @@ -if [ $commands[kops] ]; then - source <(kops completion zsh) +# Autocompletion for the Kubernetes Operations CLI (kops). +if (( ! $+commands[kops] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_kops" ]]; then + kops completion zsh | tee "$ZSH_CACHE_DIR/completions/_kops" >/dev/null + source "$ZSH_CACHE_DIR/completions/_kops" +else + source "$ZSH_CACHE_DIR/completions/_kops" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kops" + zf_mv -f -- =( kops completion zsh ) "$ZSH_CACHE_DIR/completions/_kops" + } &| fi diff --git a/plugins/oc/oc.plugin.zsh b/plugins/oc/oc.plugin.zsh index f0e2fc3bc..c2e152ac5 100644 --- a/plugins/oc/oc.plugin.zsh +++ b/plugins/oc/oc.plugin.zsh @@ -2,7 +2,20 @@ # # Author: https://github.com/kevinkirkup -if [ $commands[oc] ]; then - source <(oc completion zsh) - compdef _oc oc +if (( ! $+commands[oc] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_oc" ]]; then + oc completion zsh | tee "$ZSH_CACHE_DIR/completions/_oc" >/dev/null + source "$ZSH_CACHE_DIR/completions/_oc" +else + source "$ZSH_CACHE_DIR/completions/_oc" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._oc" + zf_mv -f -- =( oc completion zsh ) "$ZSH_CACHE_DIR/completions/_oc" + } &| fi diff --git a/plugins/operator-sdk/operator-sdk.plugin.zsh b/plugins/operator-sdk/operator-sdk.plugin.zsh index baeb01a80..2f12b1fe4 100644 --- a/plugins/operator-sdk/operator-sdk.plugin.zsh +++ b/plugins/operator-sdk/operator-sdk.plugin.zsh @@ -1,4 +1,18 @@ -if [ $commands[operator-sdk] ]; then - source <(operator-sdk completion zsh) - compdef _operator-sdk operator-sdk +# Autocompletion for the Operator SDK CLI (operator-sdk). +if (( ! $+commands[operator-sdk] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_operator-sdk" ]]; then + operator-sdk completion zsh | tee "$ZSH_CACHE_DIR/completions/_operator-sdk" >/dev/null + source "$ZSH_CACHE_DIR/completions/_operator-sdk" +else + source "$ZSH_CACHE_DIR/completions/_operator-sdk" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._operator-sdk" + zf_mv -f -- =( operator-sdk completion zsh ) "$ZSH_CACHE_DIR/completions/_operator-sdk" + } &| fi diff --git a/plugins/please/please.plugin.zsh b/plugins/please/please.plugin.zsh index 0f58307ab..e4d2a7008 100644 --- a/plugins/please/please.plugin.zsh +++ b/plugins/please/please.plugin.zsh @@ -1,5 +1,20 @@ -if (( $+commands[plz] )); then - source <(plz --completion_script) +# Autocompletion for the Please build system CLI (plz). +if (( ! $+commands[plz] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_plz" ]]; then + plz --completion_script | tee "$ZSH_CACHE_DIR/completions/_plz" >/dev/null + source "$ZSH_CACHE_DIR/completions/_plz" +else + source "$ZSH_CACHE_DIR/completions/_plz" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._plz" + zf_mv -f -- =( plz --completion_script ) "$ZSH_CACHE_DIR/completions/_plz" + } &| fi alias pb='plz build' diff --git a/plugins/svcat/svcat.plugin.zsh b/plugins/svcat/svcat.plugin.zsh index f90e7d8d6..396877d72 100644 --- a/plugins/svcat/svcat.plugin.zsh +++ b/plugins/svcat/svcat.plugin.zsh @@ -1,6 +1,18 @@ -# Autocompletion for svcat. -# +# Autocompletion for the Service Catalog CLI (svcat). +if (( ! $+commands[svcat] )); then + return +fi -if [ $commands[svcat] ]; then - source <(svcat completion zsh) +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_svcat" ]]; then + svcat completion zsh | tee "$ZSH_CACHE_DIR/completions/_svcat" >/dev/null + source "$ZSH_CACHE_DIR/completions/_svcat" +else + source "$ZSH_CACHE_DIR/completions/_svcat" + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._svcat" + zf_mv -f -- =( svcat completion zsh ) "$ZSH_CACHE_DIR/completions/_svcat" + } &| fi From aa9ca00520eff36fa9d558e237056cd1f2458764 Mon Sep 17 00:00:00 2001 From: anacletoTM <152033551+anacletoTM@users.noreply.github.com> Date: Fri, 27 Nov 2026 22:31:49 +0100 Subject: [PATCH 18/40] refactor(laravel): consolidate versioned plugins (#14282) * refactor(laravel): consolidate versioned plugins * fix(laravel): scope legacy aliases and defer command discovery --- plugins/laravel/README.md | 44 +++++++ plugins/laravel/_artisan | 30 +++-- plugins/laravel/laravel.plugin.zsh | 7 + plugins/laravel/tests/laravel.test.zsh | 171 +++++++++++++++++++++++++ plugins/laravel4/README.md | 19 +-- plugins/laravel4/laravel4.plugin.zsh | 29 ++--- plugins/laravel5/README.md | 19 +-- plugins/laravel5/laravel5.plugin.zsh | 28 ++-- 8 files changed, 280 insertions(+), 67 deletions(-) create mode 100644 plugins/laravel/tests/laravel.test.zsh diff --git a/plugins/laravel/README.md b/plugins/laravel/README.md index b790d2c81..f3205c798 100644 --- a/plugins/laravel/README.md +++ b/plugins/laravel/README.md @@ -2,10 +2,44 @@ This plugin adds aliases and autocompletion for Laravel [Artisan](https://laravel.com/docs/artisan) and [Bob](http://daylerees.github.io/laravel-bob/) command-line interfaces. +It replaces the `laravel4` and `laravel5` plugins. Enable only `laravel` to use +the shared aliases and completion with Laravel projects of different versions. + ``` plugins=(... laravel) ``` +## Completion + +For Laravel 4 and later, completion reads the available commands from +`artisan list --raw --no-ansi` in the current project, including custom commands. +The legacy static command-name completion is retained for Laravel 3, which does +not support that command. Artisan runs only when completing a command name; +command arguments use file completion without booting the application. +No Laravel command runs when the plugin is loaded. + +## Migrating from laravel4 or laravel5 + +Replace `laravel4` or `laravel5` in your `plugins` array with `laravel`. +The old plugin names still load `laravel`, with a deprecation notice, and retain +their own version-specific aliases listed below. These aliases are available +only while the corresponding legacy plugin is enabled. When switching to +`laravel` alone, use `artisan` or the shared aliases instead; add any shortcuts +you still need to your own configuration. + +| Alias | Command | +|-------|---------| +| `la4`, `la5` | `php artisan` | +| `la4dump` | `php artisan dump-autoload` | +| `la4cache`, `la5cache` | `php artisan cache:clear` | +| `la4routes` | `php artisan routes` (Laravel 4) | +| `la5routes` | `php artisan route:list` (Laravel 5 and later) | +| `la5vendor` | `php artisan vendor:publish` | + +Only commands supported by your project's Laravel version can be run. The +version-specific aliases keep their original meaning; they do not translate +commands between versions. + ## Settings By default the aliases run `php artisan`. To use a different PHP command, such as @@ -19,6 +53,16 @@ zstyle ':omz:plugins:laravel' php 'herd php' `php` in the aliases below is then replaced with that command. +For a wrapper such as `herd php`, Zsh normally attempts completion for the +wrapper after expanding the alias. To complete `artisan`, `la4`, and `la5` +directly with this plugin instead, enable Zsh's `COMPLETE_ALIASES` option: + +```zsh +setopt COMPLETE_ALIASES +``` + +This option applies to all aliases in your shell. + ## Aliases | Alias | Description | diff --git a/plugins/laravel/_artisan b/plugins/laravel/_artisan index 8637514cf..ca57f0993 100644 --- a/plugins/laravel/_artisan +++ b/plugins/laravel/_artisan @@ -8,6 +8,9 @@ # - Adds aliases and autocompletion for bob local curcontext="$curcontext" state line _opts _bundles ret=1 +local php_command command_list +local -a artisan_commands + _arguments -C \ '1: :->cmds' \ '*:: :->args' && ret=0 @@ -15,6 +18,21 @@ _arguments -C \ case $state in cmds) + # Boot the application only to discover command names, not file arguments. + # Laravel 3 falls back to the static command names below. + zstyle -s ':omz:plugins:laravel' php php_command || php_command=php + if [[ -f artisan ]] && command_list=$( + "${(@Q)${(z)php_command}}" artisan list --raw --no-ansi 2>/dev/null + ); then + artisan_commands=("${(@f)command_list}") + artisan_commands=(${artisan_commands[@]%%[[:space:]]*}) + fi + + if (( ${#artisan_commands} )); then + compadd -- "${artisan_commands[@]}" + return $? + fi + _values "Artisan command" \ 'session\:install[Create a session table]' \ 'migrate[Manage Migrations]' \ @@ -24,16 +42,8 @@ case $state in ret=0 ;; args) - case $line[1] in - migrate) - _values \ - 'install[Create the Laravel migration table' \ - 'make[Create a migration]' \ - 'rollback[Roll back to the last migration operation]' \ - 'reset[Roll back all migrations that have ever run]' - ret=0 - ;; - esac + _files + return $? ;; esac diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh index 798d81d02..b40e3a6f0 100644 --- a/plugins/laravel/laravel.plugin.zsh +++ b/plugins/laravel/laravel.plugin.zsh @@ -63,3 +63,10 @@ alias pamomr="$_omz_laravel_php artisan module:migrate-rollback" alias pamos="$_omz_laravel_php artisan module:seed" unset _omz_laravel_php + +# Also load completion when reached through a legacy plugin name. +if (( ! ${fpath[(Ie)${0:A:h}]} )); then + fpath+=("${0:A:h}") +fi +autoload -Uz _artisan +compdef _artisan artisan diff --git a/plugins/laravel/tests/laravel.test.zsh b/plugins/laravel/tests/laravel.test.zsh new file mode 100644 index 000000000..a50a2f6a6 --- /dev/null +++ b/plugins/laravel/tests/laravel.test.zsh @@ -0,0 +1,171 @@ +#!/usr/bin/env zsh + +# Run with: zsh -df plugins/laravel/tests/laravel.test.zsh +emulate -LR zsh + +plugin_dir=${0:A:h:h} +test_dir=$(mktemp -d) || exit 1 +trap 'command rm -rf -- "$test_dir"' EXIT +typeset -i tests=0 failures=0 fixture_status=0 +typeset completion_state=cmds fixture_output output + +autoload -Uz compinit +compinit -D -u + +# Record the interpreter's arguments even when invoked in a subshell. +php() { + print -rl -- "$@" >| "$test_dir/call" + print -r -- "$fixture_output" + return $fixture_status +} + +check() { + local description=$1 + shift + (( tests++ )) + if "$@"; then + print -r -- "PASS: $description" + else + print -u2 -r -- "FAIL: $description" + (( failures++ )) + fi +} + +source "$plugin_dir/laravel.plugin.zsh" +check 'plugin loading does not execute PHP' test ! -e "$test_dir/call" +check 'completion is registered for artisan' \ + test "${_comps[artisan]}" = _artisan +for name in la4 la4dump la4cache la4routes la5 la5cache la5routes la5vendor; do + check "laravel alone does not add $name" test "${+aliases[$name]}" = 0 +done +for name in la4 la5; do + check "laravel alone does not register $name completion" \ + test "${+_comps[$name]}" = 0 +done + +for entry in \ + 'pas:serve' 'pam:migrate' 'pamm:make:model' 'bob:bob::build'; do + name=${entry%%:*} + expected_command=${entry#*:} + expected_call=$'artisan\n'"$expected_command"$'\nargument with spaces' + eval "$name 'argument with spaces'" > /dev/null + check "$name preserves its command and arguments" \ + test "$(command cat -- "$test_dir/call")" = "$expected_call" +done + +# Exercise completion dispatch without requiring an interactive ZLE session. +_arguments() { state=$completion_state; line=(migrate); return 1; } +compadd() { [[ $1 == -- ]] && shift; print -rl -- "$@"; } +_values() { print -rl -- "$@"; } +_files() { print -r -- file-completion; } + +mkdir "$test_dir/project with spaces" +builtin cd "$test_dir/project with spaces" +touch artisan +fixture_output='cache:clear Clear the application cache +migrate Run migrations +project:custom Run a custom command' +output=$(_artisan) +check 'project commands, namespaces and custom commands are completed' \ + test "$output" = $'cache:clear\nmigrate\nproject:custom' +check 'completion uses the portable raw list interface' \ + test "$(command cat -- "$test_dir/call")" = $'artisan\nlist\n--raw\n--no-ansi' + +fixture_output='routes List Laravel 4 routes +dump-autoload Regenerate autoload files' +output=$(_artisan) +check 'Laravel 4 commands are discovered rather than hardcoded' \ + test "$output" = $'routes\ndump-autoload' + +completion_state=args +for fixture_status in 0 1; do + command rm -f -- "$test_dir/call" + output=$(_artisan) + check "command arguments use file completion (PHP status $fixture_status)" \ + test "$output" = file-completion + check "argument completion never boots Artisan (PHP status $fixture_status)" \ + test ! -e "$test_dir/call" +done +completion_state=cmds + +fixture_status=1 +fixture_output='Unsupported option: --raw' +output=$(_artisan) +check 'legacy Artisan retains its static completion when raw listing fails' \ + test "${output[(f)-1]}" = 'key\:\:generate[Generate a key]' +fixture_status=0 + +fixture_output='' +output=$(_artisan) +check 'an empty command list falls back to legacy completion' \ + test "${output[(f)-1]}" = 'key\:\:generate[Generate a key]' + +command rm "$test_dir/call" +builtin cd "$test_dir" +output=$(_artisan) +check 'completion outside a project does not execute PHP' \ + test ! -e "$test_dir/call" + +# A configured command may contain multiple words and quoted arguments. +wrapper() { + print -rl -- "$@" >| "$test_dir/wrapper-call" + print -r -- "$fixture_output" +} +zstyle ':omz:plugins:laravel' php 'wrapper --site "site with spaces" php' +source "$plugin_dir/../laravel5/laravel5.plugin.zsh" 2> "$test_dir/warning" +eval 'la5routes "argument with spaces"' > /dev/null +expected_call=$'--site\nsite with spaces\nphp\nartisan\nroute:list' +expected_call+=$'\nargument with spaces' +check 'legacy aliases honor a configured PHP wrapper' \ + test "$(command cat -- "$test_dir/wrapper-call")" = "$expected_call" +builtin cd "$test_dir/project with spaces" +fixture_output=$'project:custom Run a custom command' +output=$(_artisan) +expected_call=$'--site\nsite with spaces\nphp\nartisan\nlist\n--raw\n--no-ansi' +check 'completion honors a configured PHP wrapper' \ + test "$(command cat -- "$test_dir/wrapper-call")" = "$expected_call" +check 'wrapper output is completed' test "$output" = project:custom +zstyle -d ':omz:plugins:laravel' php + +for plugin in laravel4 laravel5; do + # Start a separate shell so no previously loaded completion can hide a + # missing autoload path in the compatibility plugin. + output=$(zsh -df -c ' + autoload -Uz compinit + compinit -D -u + source "$1" 2> "$2" + prefix=la${3#laravel} + for name in artisan $prefix; do + [[ ${_comps[$name]} == _artisan ]] || exit 1 + done + if [[ $prefix == la4 ]]; then + [[ ${+aliases[la5]} == 0 ]] || exit 1 + expected_aliases=( + la4 "php artisan" la4dump "php artisan dump-autoload" + la4cache "php artisan cache:clear" la4routes "php artisan routes" + ) + else + [[ ${+aliases[la4]} == 0 ]] || exit 1 + expected_aliases=( + la5 "php artisan" la5cache "php artisan cache:clear" + la5routes "php artisan route:list" + la5vendor "php artisan vendor:publish" + ) + fi + for name expected in "${expected_aliases[@]}"; do + [[ ${aliases[$name]} == "$expected" ]] || exit 1 + done + autoload +X _artisan || exit 1 + [[ ${functions_source[_artisan]} == */laravel/_artisan ]] || exit 1 + print -r -- loaded + ' zsh "$plugin_dir/../$plugin/$plugin.plugin.zsh" \ + "$test_dir/warning" "$plugin") + result=$? + check "$plugin loads the unified completion and original aliases" \ + test "$result:$output" = '0:loaded' + check "$plugin explains how to migrate" \ + test "$(command cat -- "$test_dir/warning")" != '' +done + +print -r -- "$tests tests, $failures failures" +(( failures == 0 )) diff --git a/plugins/laravel4/README.md b/plugins/laravel4/README.md index 97a6a7899..5cf50dfd6 100644 --- a/plugins/laravel4/README.md +++ b/plugins/laravel4/README.md @@ -1,18 +1,13 @@ # Laravel 4 plugin -This plugin adds some aliases for common [Laravel 4](https://laravel.com/docs/4.2) commands. - -To use it, add `laravel4` to the plugins array in your zshrc file: +This plugin is deprecated. Use the [laravel plugin](../laravel) instead: ```zsh -plugins=(... laravel4) +plugins=(... laravel) ``` -## Aliases - -| Alias | Command | Description | -|-----------|-----------------------------|-------------------------------------| -| la4 | `php artisan` | Main Artisan command | -| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files | -| la4cache | `php artisan cache:clear` | Flush the application cache | -| la4routes | `php artisan routes` | List all registered routes | +This compatibility loader sources `laravel` for shared aliases and completion, +then adds the original `la4`, `la4dump`, `la4cache`, and `la4routes` aliases. +These version-specific aliases are only available while `laravel4` is enabled. +When switching to `laravel` alone, use `artisan` or the shared aliases, or define +any shortcuts you still need in your own configuration. diff --git a/plugins/laravel4/laravel4.plugin.zsh b/plugins/laravel4/laravel4.plugin.zsh index 0edc84970..5daf8ec76 100644 --- a/plugins/laravel4/laravel4.plugin.zsh +++ b/plugins/laravel4/laravel4.plugin.zsh @@ -1,20 +1,15 @@ -# Laravel4 basic command completion -_laravel4_get_command_list () { - php artisan --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }' -} +print -Pru2 -- \ + '%F{yellow}[oh-my-zsh] The %Blaravel4%b plugin is deprecated.' \ + 'Use %Blaravel%b instead.%f' -_laravel4 () { - if [ -f artisan ]; then - compadd `_laravel4_get_command_list` - fi -} +source "${0:A:h:h}/laravel/laravel.plugin.zsh" -compdef _laravel4 artisan -compdef _laravel4 la4 +# Keep compatibility aliases scoped to users of this legacy plugin. +zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php +alias la4="$_omz_laravel_php artisan" +alias la4dump="$_omz_laravel_php artisan dump-autoload" +alias la4cache="$_omz_laravel_php artisan cache:clear" +alias la4routes="$_omz_laravel_php artisan routes" +unset _omz_laravel_php -#Alias -alias la4='php artisan' - -alias la4dump='php artisan dump-autoload' -alias la4cache='php artisan cache:clear' -alias la4routes='php artisan routes' +compdef _artisan la4 diff --git a/plugins/laravel5/README.md b/plugins/laravel5/README.md index 933342a9e..cccfa6156 100644 --- a/plugins/laravel5/README.md +++ b/plugins/laravel5/README.md @@ -1,18 +1,13 @@ # Laravel 5 plugin -This plugin adds some aliases for common [Laravel 5](https://laravel.com/docs) commands. - -To use it, add `laravel5` to the plugins array in your zshrc file: +This plugin is deprecated. Use the [laravel plugin](../laravel) instead: ```zsh -plugins=(... laravel5) +plugins=(... laravel) ``` -## Aliases - -| Alias | Command | Description | -|-----------|------------------------------|----------------------------------------------------| -| la5 | `php artisan` | Main Artisan command | -| la5cache | `php artisan cache:clear` | Flush the application cache | -| la5routes | `php artisan route:list` | List all registered routes | -| la5vendor | `php artisan vendor:publish` | Publish any publishable assets from vendor package | +This compatibility loader sources `laravel` for shared aliases and completion, +then adds the original `la5`, `la5cache`, `la5routes`, and `la5vendor` aliases. +These version-specific aliases are only available while `laravel5` is enabled. +When switching to `laravel` alone, use `artisan` or the shared aliases, or define +any shortcuts you still need in your own configuration. diff --git a/plugins/laravel5/laravel5.plugin.zsh b/plugins/laravel5/laravel5.plugin.zsh index 70dc4ed02..aa28938ce 100644 --- a/plugins/laravel5/laravel5.plugin.zsh +++ b/plugins/laravel5/laravel5.plugin.zsh @@ -1,19 +1,15 @@ -# Alias -alias la5='php artisan' -alias la5cache='php artisan cache:clear' -alias la5routes='php artisan route:list' -alias la5vendor='php artisan vendor:publish' +print -Pru2 -- \ + '%F{yellow}[oh-my-zsh] The %Blaravel5%b plugin is deprecated.' \ + 'Use %Blaravel%b instead.%f' -# Laravel5 basic command completion -_laravel5_get_command_list () { - php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g" -} +source "${0:A:h:h}/laravel/laravel.plugin.zsh" -_laravel5 () { - if [[ -f artisan ]]; then - compadd $(_laravel5_get_command_list) - fi -} +# Keep compatibility aliases scoped to users of this legacy plugin. +zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php +alias la5="$_omz_laravel_php artisan" +alias la5cache="$_omz_laravel_php artisan cache:clear" +alias la5routes="$_omz_laravel_php artisan route:list" +alias la5vendor="$_omz_laravel_php artisan vendor:publish" +unset _omz_laravel_php -compdef _laravel5 artisan -compdef _laravel5 la5 +compdef _artisan la5 From 2cd4cc21fc5c0060699702406e6d05840cc49561 Mon Sep 17 00:00:00 2001 From: Hegui Dai Date: Sat, 28 Nov 2026 06:45:52 +0800 Subject: [PATCH 19/40] feat(jj): add `jjgpb` alias for `jj git push --bookmark` (#14302) --- plugins/jj/README.md | 1 + plugins/jj/jj.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/jj/README.md b/plugins/jj/README.md index 758fd554a..51ad87fae 100644 --- a/plugins/jj/README.md +++ b/plugins/jj/README.md @@ -44,6 +44,7 @@ plugins=(... jj) | jjgi | `jj git init` | | jjgp | `jj git push` | | jjgpa | `jj git push --all` | +| jjgpb | `jj git push --bookmark` | | jjgpd | `jj git push --deleted` | | jjgpt | `jj git push --tracked` | | jjgrl | `jj git remote list` | diff --git a/plugins/jj/jj.plugin.zsh b/plugins/jj/jj.plugin.zsh index 50f85b6ef..b46603128 100644 --- a/plugins/jj/jj.plugin.zsh +++ b/plugins/jj/jj.plugin.zsh @@ -70,6 +70,7 @@ alias jjgfa='jj git fetch --all-remotes' alias jjgi='jj git init' alias jjgp='jj git push' alias jjgpa='jj git push --all' +alias jjgpb='jj git push --bookmark' alias jjgpd='jj git push --deleted' alias jjgpt='jj git push --tracked' alias jjgrl='jj git remote list' From 32726ad0a561e222e2d7653d3c6fd4cb879ee587 Mon Sep 17 00:00:00 2001 From: Sanjay Doppalapudi <80777235+Sanjay-doppalapudi@users.noreply.github.com> Date: Fri, 27 Nov 2026 16:46:04 -0600 Subject: [PATCH 20/40] fix(extract): unpack `.tar.lzma` archives (#14298) --- plugins/extract/README.md | 1 + plugins/extract/_extract | 1 + plugins/extract/extract.plugin.zsh | 2 +- plugins/extract/tests/extract.test.zsh | 6 +++++- 4 files changed, 8 insertions(+), 2 deletions(-) mode change 100755 => 100644 plugins/extract/extract.plugin.zsh diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 7bedfb1c6..9cc688f6a 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -45,6 +45,7 @@ plugins=(... extract) | `tar.lrz` | Tarball with lrzip compression | | `tar.lz` | Tarball with lzip compression | | `tar.lz4` | Tarball with lz4 compression | +| `tar.lzma` | Tarball with lzma compression | | `tar.xz` | Tarball with lzma2 compression | | `tar.zma` | Tarball with lzma compression | | `tar.zst` | Tarball with zstd compression | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 7d71aeb1b..7e89ba98a 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -31,6 +31,7 @@ local -a exts=( tar.lrz tar.lz tar.lz4 + tar.lzma tar.xz tar.zma tar.zst diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh old mode 100755 new mode 100644 index bd8e73d6e..51a4522ed --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -88,7 +88,7 @@ EOF tar --xz --help &> /dev/null \ && tar --xz -xvf "$full_path" \ || xzcat "$full_path" | tar xvf - } ;; - (*.tar.zma|*.tlz) + (*.tar.lzma|*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$full_path" \ || lzcat "$full_path" | tar xvf - ;; diff --git a/plugins/extract/tests/extract.test.zsh b/plugins/extract/tests/extract.test.zsh index 180fce046..9d8f2485b 100644 --- a/plugins/extract/tests/extract.test.zsh +++ b/plugins/extract/tests/extract.test.zsh @@ -167,7 +167,11 @@ check_deb_multiple() { printf '\037\235\220\150\312\260\141\363\106\001' \ > "$test_dir/fixture.Z" - for extension in lzma Z; do + cp "$test_dir/plain" "$test_dir/sample.txt" + tar -cf "$test_dir/fixture.tar" -C "$test_dir" sample.txt + lzma -c "$test_dir/fixture.tar" > "$test_dir/fixture.tar.lzma" + + for extension in lzma Z tar.lzma; do for mode in default target remove; do check_extract "$extension" "$mode" done From 387dfe0bfb85126839ffed9a7b13558dd972230e Mon Sep 17 00:00:00 2001 From: Rasmus Skovgaard Lauritsen Date: Fri, 27 Nov 2026 23:46:09 +0100 Subject: [PATCH 21/40] feat(fizzy): add completion plugin (#14297) --- plugins/fizzy/README.md | 18 ++++++++++++++++++ plugins/fizzy/fizzy.plugin.zsh | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 plugins/fizzy/README.md create mode 100644 plugins/fizzy/fizzy.plugin.zsh diff --git a/plugins/fizzy/README.md b/plugins/fizzy/README.md new file mode 100644 index 000000000..cb19b1a97 --- /dev/null +++ b/plugins/fizzy/README.md @@ -0,0 +1,18 @@ +# Fizzy CLI plugin + +This plugin adds completion for the [Fizzy CLI (fizzy)](https://github.com/basecamp/fizzy-cli). + +To use it, add `fizzy` to the plugins array in your zshrc file: + +```zsh +plugins=(... fizzy) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and automatically updates it when the +plugin is loaded, which is usually when you start a new terminal emulator. + +The cache is stored at `$ZSH_CACHE_DIR/completions/_fizzy`. diff --git a/plugins/fizzy/fizzy.plugin.zsh b/plugins/fizzy/fizzy.plugin.zsh new file mode 100644 index 000000000..9dd50ab25 --- /dev/null +++ b/plugins/fizzy/fizzy.plugin.zsh @@ -0,0 +1,24 @@ +# Autocompletion for the Fizzy CLI (fizzy). +if (( ! $+commands[fizzy] )); then + return +fi + +# If the completion isn't registered yet, autoload it and bind it to `fizzy`. +# Otherwise, compinit will have already done that from the cache. +if [[ -z ${_comps[fizzy]-} ]]; then + typeset -g -A _comps + autoload -Uz _fizzy + _comps[fizzy]=_fizzy +fi + +zmodload -F zsh/files b:zf_mv || return +() { + local cache_file="$ZSH_CACHE_DIR/completions/_fizzy" + local temp_file + temp_file=$(mktemp "$ZSH_CACHE_DIR/completions/._fizzy.XXXXXXXX") || return + if command fizzy completion zsh >| "$temp_file" && [[ -s "$temp_file" ]] && + zf_mv -f -- "$temp_file" "$cache_file"; then + return + fi + rm -f -- "$temp_file" +} &| From 1dc43bfe53c109450fc7aaecfa683cd1b88c30f2 Mon Sep 17 00:00:00 2001 From: gbaian10 Date: Sat, 28 Nov 2026 06:46:13 +0800 Subject: [PATCH 22/40] fix(pre-commit): use `autoupdate` for prek (#14295) Closes #14294 --- plugins/pre-commit/README.md | 2 +- plugins/pre-commit/pre-commit.plugin.zsh | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/pre-commit/README.md b/plugins/pre-commit/README.md index 06dc6e442..c7810ebea 100644 --- a/plugins/pre-commit/README.md +++ b/plugins/pre-commit/README.md @@ -15,7 +15,7 @@ plugins=(... pre-commit) | Alias | Command | Description | | ----- | ------------------------------------------------------ | --------------------------------------------- | | prc | `prek` or `pre-commit` | The pre-commit command | -| prcau | `prek auto-update` or `pre-commit autoupdate` | Update hooks automatically | +| prcau | `prek autoupdate` or `pre-commit autoupdate` | Update hooks automatically | | prcr | `prek run` or `pre-commit run` | The pre-commit run command | | prcra | `prek run --all-files` or `pre-commit run --all-files` | Run pre-commit hooks on all files | | prcrf | `prek run --files` or `pre-commit run --files` | Run pre-commit hooks on a given list of files | diff --git a/plugins/pre-commit/pre-commit.plugin.zsh b/plugins/pre-commit/pre-commit.plugin.zsh index 11219fed2..470dbc084 100644 --- a/plugins/pre-commit/pre-commit.plugin.zsh +++ b/plugins/pre-commit/pre-commit.plugin.zsh @@ -1,15 +1,13 @@ # Aliases for pre-commit (uses prek if available, else pre-commit) if command -v prek &> /dev/null; then _prc_cmd='prek' - _prc_autoupdate='auto-update' else _prc_cmd='pre-commit' - _prc_autoupdate='autoupdate' fi alias prc="$_prc_cmd" -alias prcau="$_prc_cmd $_prc_autoupdate" +alias prcau="$_prc_cmd autoupdate" alias prcr="$_prc_cmd run" alias prcra="$_prc_cmd run --all-files" From 90e5779f1f32588c3dd85f0435c061d96e3b59bc Mon Sep 17 00:00:00 2001 From: Hobeom Jeon Date: Sat, 28 Nov 2026 07:54:06 +0900 Subject: [PATCH 23/40] feat(zellij): add zellij plugin (#13624) --- plugins/zellij/README.md | 43 ++++++++++++++++++ plugins/zellij/zellij.plugin.zsh | 77 ++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 plugins/zellij/README.md create mode 100644 plugins/zellij/zellij.plugin.zsh diff --git a/plugins/zellij/README.md b/plugins/zellij/README.md new file mode 100644 index 000000000..ab03cdba2 --- /dev/null +++ b/plugins/zellij/README.md @@ -0,0 +1,43 @@ +# zellij + +This plugin provides aliases, functions, and completions for [zellij](https://zellij.dev/), +the terminal workspace (multiplexer). To use it, add `zellij` to the plugins array in your +zshrc file. + +```zsh +plugins=(... zellij) +``` + +## Aliases + +| Alias | Command | Description | +| ------ | ---------------------------- | --------------------------- | +| `zj` | `zellij` | Zellij command | +| `zjl` | `zellij list-sessions` | List sessions | +| `zjs` | `zellij -s` | Start a named session | +| `zjda` | `zellij delete-all-sessions` | Delete all sessions | +| `zjka` | `zellij kill-all-sessions` | Kill all sessions | +| `zjr` | `zellij run` | Run a command in a pane | +| `zjad` | `zellij action detach` | Detach from current session | + +## Functions + +| Function | Command | Description | +| -------- | -------------------------------- | -------------------------------- | +| `zja` | `zellij attach` | Attach to a session | +| `zjd` | `zellij delete-session` | Delete a session (exited only) | +| `zjdf` | `zellij delete-session --force` | Force-delete any session | +| `zjk` | `zellij kill-session` | Kill a session | +| `zjas` | `zellij action switch-session` | Switch to a session | +| `zjrf` | `zellij run --floating --` | Run a command in a floating pane | +| `zje` | `zellij edit` | Edit a file in a pane | + +## Completions + +This plugin caches the zellij completion script. On first load the cache is generated +synchronously; subsequent updates (when the `zellij` binary is newer than the cache) happen in +the background. The cache is written to a temporary file and moved into place, so a +partially written file is never loaded. + +Session-aware completions are provided for `zja`, `zjdf` and `zjas` (all sessions), `zjk` +(running sessions) and `zjd` (exited sessions). diff --git a/plugins/zellij/zellij.plugin.zsh b/plugins/zellij/zellij.plugin.zsh new file mode 100644 index 000000000..e083e8edc --- /dev/null +++ b/plugins/zellij/zellij.plugin.zsh @@ -0,0 +1,77 @@ +if (( ! $+commands[zellij] )); then + return +fi + +# Aliases +alias zj='zellij' +alias zjl='zellij list-sessions' +alias zjs='zellij -s' +alias zjda='zellij delete-all-sessions' +alias zjka='zellij kill-all-sessions' +alias zjr='zellij run' +alias zjad='zellij action detach' + +# Functions (with session-aware completion) +function zja { command zellij attach "$@"; } +function zjd { command zellij delete-session "$@"; } +function zjdf { command zellij delete-session --force "$@"; } +function zjk { command zellij kill-session "$@"; } +function zjas { command zellij action switch-session "$@"; } + +# Convenience functions +function zjrf { command zellij run --floating -- "$@"; } +function zje { command zellij edit "$@"; } + +# Completion cache: generate synchronously on first load, regenerate in the +# background when the zellij binary is newer than the cache. Write to a temp +# file in the same directory and rename it, so a partial file is never loaded. +_omz_zellij_gen_completion() { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zellij" + zf_mv -f -- =( command zellij setup --generate-completion zsh 2>/dev/null ) "$ZSH_CACHE_DIR/completions/_zellij" +} + +zmodload -F zsh/files b:zf_mv +if [[ ! -s "$ZSH_CACHE_DIR/completions/_zellij" ]]; then + _omz_zellij_gen_completion +elif [[ $commands[zellij] -nt "$ZSH_CACHE_DIR/completions/_zellij" ]]; then + _omz_zellij_gen_completion &| +fi + +_omz_zellij_ls_raw() { + command zellij list-sessions --no-formatting 2>/dev/null || command zellij list-sessions 2>/dev/null +} + +_omz_zellij_session_names() { + # Use --short if available (zellij >= 0.44), fall back to sed parsing + command zellij list-sessions --short --no-formatting 2>/dev/null \ + || _omz_zellij_ls_raw | LC_ALL=C sed -nE 's/^([^[:space:]]+).*/\1/p' +} + +_omz_zellij_all_sessions() { + emulate -L zsh + local -a sessions + sessions=(${(f)"$(_omz_zellij_session_names)"}) + (( ${#sessions} )) && compadd -Q -a sessions +} + +_omz_zellij_running_sessions() { + emulate -L zsh + local -a sessions + sessions=(${(f)"$(_omz_zellij_ls_raw | LC_ALL=C sed -nE '/\(EXITED/!s/^([^[:space:]]+).*/\1/p')"}) + (( ${#sessions} )) && compadd -Q -a sessions +} + +_omz_zellij_exited_sessions() { + emulate -L zsh + local -a sessions + sessions=(${(f)"$(_omz_zellij_ls_raw | LC_ALL=C sed -nE '/\(EXITED/s/^([^[:space:]]+).*/\1/p')"}) + (( ${#sessions} )) && compadd -Q -a sessions +} + +if (( $+functions[compdef] )); then + autoload -Uz _zellij + compdef _zellij zellij + compdef _omz_zellij_all_sessions zja zjdf zjas + compdef _omz_zellij_running_sessions zjk + compdef _omz_zellij_exited_sessions zjd +fi From d4197927619e39a890d240461e2990ad2e16f6a2 Mon Sep 17 00:00:00 2001 From: Hobeom Jeon Date: Sat, 28 Nov 2026 07:54:10 +0900 Subject: [PATCH 24/40] feat(conda): add environment completion for cna and cnrn (#13632) --- plugins/conda/README.md | 14 +++++++++++--- plugins/conda/conda.plugin.zsh | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/plugins/conda/README.md b/plugins/conda/README.md index 70530d01e..0cd88ce55 100644 --- a/plugins/conda/README.md +++ b/plugins/conda/README.md @@ -1,6 +1,6 @@ # conda plugin -The conda plugin provides [aliases](#aliases) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html). +The conda plugin provides [aliases](#aliases) and [completion](#completion) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html). To use it, add `conda` to the plugins array in your zshrc file: @@ -28,10 +28,18 @@ plugins=(... conda) | `cnle` | `conda list --export` | Export the list of installed packages in the current environment | | `cnles` | `conda list --explicit > spec-file.txt` | Export the list of installed packages in the current environment to a spec file | | `cnr` | `conda remove` | Remove given package | -| `cnrn` | `conda remove -y -all -n` | Remove all packages in the specified environment | -| `cnrp` | `conda remove -y -all -p` | Remove all packages in the specified prefix | +| `cnrn` | `conda remove -y --all -n` | Remove all packages in the specified environment | +| `cnrp` | `conda remove -y --all -p` | Remove all packages in the specified prefix | | `cnry` | `conda remove -y` | Remove given package without confirmation | | `cnsr` | `conda search` | Search conda repositories for package | | `cnu` | `conda update` | Update conda package manager | | `cnua` | `conda update --all` | Update all installed packages | | `cnuc` | `conda update conda` | Update conda package manager | + +## Completion + +Tab completion is available for the following commands, using the environment list conda keeps in +`~/.conda/environments.txt`: + +- `cna`: completes environment names for `conda activate` +- `cnrn`: completes environment names for `conda remove -y --all -n` diff --git a/plugins/conda/conda.plugin.zsh b/plugins/conda/conda.plugin.zsh index 7a130ba7b..e99999ec3 100644 --- a/plugins/conda/conda.plugin.zsh +++ b/plugins/conda/conda.plugin.zsh @@ -1,4 +1,7 @@ -alias cna='conda activate' +unalias cna cnrn 2>/dev/null +cna() { conda activate "$@"; } +cnrn() { conda remove -y --all -n "$@"; } + alias cnab='conda activate base' alias cncf='conda env create -f' alias cncn='conda create -y -n' @@ -14,10 +17,26 @@ alias cnl='conda list' alias cnle='conda list --export' alias cnles='conda list --explicit > spec-file.txt' alias cnr='conda remove' -alias cnrn='conda remove -y --all -n' alias cnrp='conda remove -y --all -p' alias cnry='conda remove -y' alias cnsr='conda search' alias cnu='conda update' alias cnua='conda update --all' alias cnuc='conda update conda' + +_omz_conda_envs() { + emulate -L zsh -o extended_glob + local envs_file="$HOME/.conda/environments.txt" + [[ -r "$envs_file" ]] || return 1 + + # Each line is an env prefix; named envs live under /envs/. + # The root prefix (base) and envs created with -p have no name and are skipped. + local -aU envs + envs=(${(f)"$(<$envs_file)"}) + envs=(${${(M)envs:#*/envs/[^/]##}:t}) + (( ${#envs} )) && compadd -Q -a envs +} + +if (( $+functions[compdef] )); then + compdef _omz_conda_envs cna cnrn +fi From 507561c236b4c5723cbbc12939e26ce7712f0b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Darm=C3=BCntzel?= Date: Fri, 27 Nov 2026 23:58:20 +0100 Subject: [PATCH 25/40] fix(macos): set shuffle with Music's shuffle property in `music shuffle` (#13365) --- plugins/macos/music | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/macos/music b/plugins/macos/music index 50566797b..d542d179f 100644 --- a/plugins/macos/music +++ b/plugins/macos/music @@ -72,11 +72,6 @@ EOF return 0 ;; shuf|shuff|shuffle) - # The shuffle property of current playlist can't be changed in iTunes 12, - # so this workaround uses AppleScript to simulate user input instead. - # Defaults to toggling when no options are given. - # The toggle option depends on the shuffle button being visible in the Now playing area. - # On and off use the menu bar items. local state=$1 if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then @@ -85,16 +80,24 @@ EOF fi case "$state" in - on|off) - # Inspired by: https://stackoverflow.com/a/14675583 - osascript >/dev/null 2>&1 </dev/null 2>&1 </dev/null < Date: Sat, 28 Nov 2026 04:49:41 +0530 Subject: [PATCH 26/40] fix(cli): remove adjacent plugins in `omz plugin disable` (#14303) --- lib/cli.zsh | 22 +++++++++++------- lib/tests/cli.test.zsh | 51 +++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 59873368b..fe6f7667f 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -295,17 +295,23 @@ function _omz::plugin::disable { fi # Remove plugins substitution awk script + # A match consumes the whitespace around the plugin, so adjacent plugins + # can't match in the same pass: repeat until the line stops changing. local awk_subst_plugins="\ - 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 + do { + prev = \$0 - 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(/[ \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})\)/, \")\") # with BOL and closing parenthesis - gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL + 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 + } while (\$0 != prev) " # Disable plugins awk script diff --git a/lib/tests/cli.test.zsh b/lib/tests/cli.test.zsh index 9ee5cd219..0dca1e65e 100644 --- a/lib/tests/cli.test.zsh +++ b/lib/tests/cli.test.zsh @@ -7,16 +7,20 @@ run_awk() { (( ! DEBUG )) || set -xv local awk_subst_plugins="\ - 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 + do { + prev = \$0 - 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(/[ \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})\)/, \")\") # with BOL and closing parenthesis - gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL + 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 + } while (\$0 != prev) " # Disable plugins awk script local awk_script=" @@ -167,3 +171,34 @@ z)" \ "plugins=( git )" + +run_awk_and_test \ + "it should delete two adjacent plugins among others in oneline format" \ + "docker kubectl" \ + "plugins=(git docker kubectl npm)" \ + "plugins=(git npm)" + +run_awk_and_test \ + "it should delete three adjacent plugins among others in oneline format" \ + "docker kubectl aws" \ + "plugins=(git docker kubectl aws npm)" \ + "plugins=(git npm)" + +run_awk_and_test \ + "it should delete every plugin of a long oneline list" \ + "git docker kubectl aws npm z" \ + "plugins=(git docker kubectl aws npm z)" \ + "plugins=()" + +run_awk_and_test \ + "it should delete adjacent plugins sharing a line in multiline format" \ + "docker kubectl aws" \ +"plugins=( + git + docker kubectl aws + npm +)" \ +"plugins=( + git + npm +)" From da85047297d367ffc1634d92398900c61bca0a53 Mon Sep 17 00:00:00 2001 From: Sam Thomas <10165959+samuelfullerthomas@users.noreply.github.com> Date: Fri, 27 Nov 2026 23:33:06 +0000 Subject: [PATCH 27/40] fix(updater): bypass aliases when calling zsh in update check (#14178) --- tools/check_for_upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index a2597bf07..3e48b6ca9 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -160,13 +160,13 @@ function update_ohmyzsh() { fi if [[ "$update_mode" != background-alpha ]] \ - && LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days; then + && LANG= ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days; then update_last_updated_file return $? fi local exit_status error - if error=$(LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v silent -c $cooldown_days 2>&1); then + if error=$(LANG= ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v silent -c $cooldown_days 2>&1); then update_last_updated_file 0 "Update successful" else exit_status=$? From 22c883efa4217de14b7505c12ad297edb8aae9b0 Mon Sep 17 00:00:00 2001 From: Sam Thomas <10165959+samuelfullerthomas@users.noreply.github.com> Date: Fri, 27 Nov 2026 23:33:11 +0000 Subject: [PATCH 28/40] fix(dotenv): bypass aliases when checking .env syntax (#14179) --- plugins/dotenv/dotenv.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 72839a501..4ff34ab7d 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -263,9 +263,9 @@ _dotenv_check_syntax() { local filename="$1" if (( $# == 2 )); then - printf '%s' "$2" | zsh -fn /dev/stdin + printf '%s' "$2" | command zsh -fn /dev/stdin else - zsh -fn -- "$filename" + command zsh -fn -- "$filename" fi || { echo "dotenv: error when sourcing '$filename' file" >&2 return 1 From 80ec81e3401affb70777a1a9a44b71c3391989b5 Mon Sep 17 00:00:00 2001 From: Marco Trevisan Date: Sat, 28 Nov 2026 01:19:24 +0100 Subject: [PATCH 29/40] feat(clipboard): add OSC 52 fallback (#14251) OSC 52 makes the terminal emulator set the clipboard of the machine the user is connected from, which is the only way to copy to it when running over SSH or inside a container with no access to the local display server. Use it when no other clipboard tool is available, or when ZSH_CLIPBOARD_OSC52 is set to "always"; set it to "never" to disable the fallback. OSC 52 is write-only in practice, so clippaste keeps failing unless a real clipboard tool is available. Closes #13459 --- lib/clipboard.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index c9306b0f8..44e81e701 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -16,6 +16,10 @@ # - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ # - win32yank (Windows) # - tmux (if $TMUX is set) +# - OSC 52 (when no clipboard tool is available, e.g. over SSH or in a container) +# +# Set ZSH_CLIPBOARD_OSC52 to "always" to copy through OSC 52 even if a +# clipboard tool is available, or to "never" to disable the fallback. # # Defines two functions, clipcopy and clippaste, based on the detected platform. ## @@ -48,6 +52,22 @@ # # Paste to a file # clippaste > file.txt # +function _has_osc52_clipboard() { + [[ -n "${TTY:-}" ]] && [[ -w "${TTY}" ]] && (( ${+commands[base64]} )) +} + +function _clipcopy_osc52() { + emulate -L zsh + local content + content=$(cat "${1:-/dev/stdin}" | base64 | tr -d '\n') || return 1 + print -rn -- $'\e]52;c;'"${content}"$'\e\\' > /dev/tty +} + +function _clippaste_osc52() { + print 'clippaste: OSC 52 is write-only and no other clipboard tool was found' >&2 + return 1 +} + function detect-clipboard() { emulate -L zsh @@ -87,6 +107,9 @@ function detect-clipboard() { elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer -w "${1:--}"; } function clippaste() { tmux save-buffer -; } + elif [[ "${ZSH_CLIPBOARD_OSC52:-}" != never ]] && _has_osc52_clipboard; then + function clipcopy() { _clipcopy_osc52 "$@"; } + function clippaste() { _clippaste_osc52; } else function _retry_clipboard_detection_or_fail() { local clipcmd="${1}"; shift @@ -101,6 +124,10 @@ function detect-clipboard() { function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } return 1 fi + + if [[ "${ZSH_CLIPBOARD_OSC52:-}" == always ]] && _has_osc52_clipboard; then + function clipcopy() { _clipcopy_osc52 "$@"; } + fi } function clipcopy clippaste { From 597dff94776262c27dd3cafd7410e29a778b9d87 Mon Sep 17 00:00:00 2001 From: PerryLink Date: Sat, 28 Nov 2026 08:19:46 +0800 Subject: [PATCH 30/40] fix(extract): untar `.tar.Z` and `.taz` archives (#14223) --- plugins/extract/README.md | 2 ++ plugins/extract/extract.plugin.zsh | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 9cc688f6a..623fd90a1 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -49,6 +49,8 @@ plugins=(... extract) | `tar.xz` | Tarball with lzma2 compression | | `tar.zma` | Tarball with lzma compression | | `tar.zst` | Tarball with zstd compression | +| `tar.Z` | Tarball with compress (LZW) compression | +| `taz` | Tarball with compress (LZW) compression | | `tbz` | Tarball with bzip compression | | `tbz2` | Tarball with bzip2 compression | | `tgz` | Tarball with gzip compression | diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 51a4522ed..966c00bab 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -97,6 +97,11 @@ EOF && tar --zstd -xvf "$full_path" \ || zstdcat "$full_path" | tar xvf - ;; (*.tar) tar xvf "$full_path" ;; + # `tar cf - dir | compress > dir.tar.Z`: the plain `.Z` arm below only decompresses the + # stream back to `dir.tar`, so the combined form has to untar it in one step. `.taz` is the + # historic name for the same file, next to `.tgz`/`.tbz`/`.tlz`/`.txz`/`.tzst`. Matching is + # on the lowercased name, so `.tar.Z` lands here too. + (*.tar.z|*.taz) uncompress -c "$full_path" | tar xvf - ;; (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;; (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;; (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;; From 03ba23c9f6dc378ec485111613b04b3bb2335360 Mon Sep 17 00:00:00 2001 From: alexanderxc <77030694+alexanderxc@users.noreply.github.com> Date: Sat, 28 Nov 2026 01:19:51 +0100 Subject: [PATCH 31/40] chore(brew): use `bu` instead of `bubo` in `bubu` (#14229) --- plugins/brew/README.md | 2 +- plugins/brew/brew.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 5e3e3fab6..d343414e8 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -59,7 +59,7 @@ ensures the `bdr` alias runs without warnings. | `bsra` | `bsr --all` | Run all stopped services. | | `bu` | `brew update` | Update brew and all installed formulae. | | `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | -| `bubu` | `bubo && bup` | Do the last two operations above. | +| `bubu` | `bu && bup` | Update Homebrew data, then upgrade outdated, unpinned brews. | | `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. | | `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. | | `buz` | `brew uninstall --zap` | Remove all files associated with a cask. | diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 45cd89f44..0b17bc7c6 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -75,7 +75,7 @@ alias bsr='brew services run' alias bsra='bsr --all' alias bu='brew update' alias bubo='brew update && brew outdated' -alias bubu='bubo && bup' +alias bubu='bu && bup' alias bubug='bubo && bugbc' alias bugbc='brew upgrade --greedy && brew cleanup' alias bup='brew upgrade' From 5873e1cfec6031aa35119ce5b8d37763e95db1f6 Mon Sep 17 00:00:00 2001 From: Jakub Boukal Date: Sat, 28 Nov 2026 01:20:27 +0100 Subject: [PATCH 32/40] docs(python): add `PYTHON_AUTO_VRUN` to settings (#14233) --- plugins/python/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/python/README.md b/plugins/python/README.md index beab84a01..0ded7d9d1 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -46,6 +46,7 @@ You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced. For example: ```sh +PYTHON_AUTO_VRUN=true PYTHON_VENV_NAME=".venv" PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv) ... @@ -54,6 +55,14 @@ source "$ZSH/oh-my-zsh.sh" ``` +## `$PYTHON_AUTO_VRUN` + +**Default**: `false`. + +Enable automatic activation of virtual environments when entering a directory containing +`/bin/activate`, and automatically deactivate it when navigating out of it. +Set to `true` to enable this feature. + ## `$PYTHON_VENV_NAME` **Default**: `venv`. From 5c7cd916157a49ea8514c38388088776b0db26a9 Mon Sep 17 00:00:00 2001 From: Sri Harsha Ponukumati <53646447+hponukumati@users.noreply.github.com> Date: Fri, 27 Nov 2026 18:30:43 -0800 Subject: [PATCH 33/40] fix(uninstall): prompt before restoring pre-OMZ zshrc backup (#13849) Fixes #13156 Fixes #13328 --- tools/uninstall.sh | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tools/uninstall.sh b/tools/uninstall.sh index 6e3df7aca..481281abc 100644 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -23,18 +23,47 @@ fi if [ -e ~/.zshrc ]; then ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S) - echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}" + echo "Found ~/.zshrc -- Saving your current config to ${ZSHRC_SAVE}" + echo " (this file contains your current zsh configuration)" mv ~/.zshrc "${ZSHRC_SAVE}" fi echo "Looking for original zsh config..." ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh if [ -e "$ZSHRC_ORIG" ]; then - echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc" - mv "$ZSHRC_ORIG" ~/.zshrc - echo "Your original zsh config was restored." + ZSHRC_ORIG_DATE=$(date -r "$ZSHRC_ORIG" "+%Y-%m-%d" 2>/dev/null || date -d "@$(stat -c %Y "$ZSHRC_ORIG" 2>/dev/null)" "+%Y-%m-%d" 2>/dev/null || echo "unknown date") + echo "Found $ZSHRC_ORIG (last modified: ${ZSHRC_ORIG_DATE})" + echo "This is the zsh config that existed before Oh My Zsh was installed." + printf "Restore it as ~/.zshrc? [y/N] " + read -r restore_confirmation + if [ "$restore_confirmation" = y ] || [ "$restore_confirmation" = Y ]; then + mv "$ZSHRC_ORIG" ~/.zshrc + echo "Your original zsh config was restored to ~/.zshrc." + if [ -n "$ZSHRC_SAVE" ]; then + echo "Your Oh My Zsh config is saved at ${ZSHRC_SAVE} if you need it." + fi + else + echo "Skipping restore." + if [ -n "$ZSHRC_SAVE" ]; then + mv "${ZSHRC_SAVE}" ~/.zshrc + echo "Your current zsh config has been kept at ~/.zshrc." + echo "Your pre-OMZ backup is still at ${ZSHRC_ORIG} if you need it." + fi + fi else - echo "No original zsh config found" + echo "No original zsh config found." + if [ -n "$ZSHRC_SAVE" ]; then + mv "${ZSHRC_SAVE}" ~/.zshrc + echo "Your current zsh config has been kept at ~/.zshrc." + fi +fi + +# Warn if the active .zshrc still sources oh-my-zsh +if [ -f ~/.zshrc ] && command grep -q 'source.*oh-my-zsh\.sh' ~/.zshrc 2>/dev/null; then + echo "" + echo "Note: ~/.zshrc still contains a line sourcing oh-my-zsh.sh." + echo "Since oh-my-zsh has been removed, that line will cause an error" + echo "on every new shell. You may want to remove or comment it out." fi echo "Thanks for trying out Oh My Zsh. It's been uninstalled." From 71679f351ddf00b7c0d9cf58e69e092816148626 Mon Sep 17 00:00:00 2001 From: 180909 <734461790@qq.com> Date: Sat, 28 Nov 2026 10:32:08 +0800 Subject: [PATCH 34/40] feat(golang): add `goge` alias for `go generate` (#11528) * feat(golang): add `goge` alias for `go generate` * feat(golang):update sequence --- plugins/golang/README.md | 2 ++ plugins/golang/golang.plugin.zsh | 1 + 2 files changed, 3 insertions(+) diff --git a/plugins/golang/README.md b/plugins/golang/README.md index 610952d6d..7a9967749 100644 --- a/plugins/golang/README.md +++ b/plugins/golang/README.md @@ -22,6 +22,7 @@ plugins=(... golang) | gofx | `go fix` | Update packages to use a new API | | gog | `go get` | Downloads packages and then installs them to $GOPATH | | goga | `go get ./...` | Installs all dependencies in current directory, recursively | +| goge | `go generate` | Generate Go files by processing source | | goi | `go install` | Compiles and installs packages to $GOPATH | | gol | `go list` | Lists Go packages | | gom | `go mod` | Access to operations on modules | @@ -54,3 +55,4 @@ changes your prompt to: ``` ~/go/project$ ▋ 1.22.3 ``` + diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 48908b5d9..2e5e18fa7 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -19,6 +19,7 @@ alias gofa='go fmt ./...' alias gofx='go fix' alias gog='go get' alias goga='go get ./...' +alias goge='go generate' alias goi='go install' alias gol='go list' alias gom='go mod' From 4ec1d1707432daeb9891cf4f4e8e657bf04e68e6 Mon Sep 17 00:00:00 2001 From: Jans Rautenbach <14095706+J4NS-R@users.noreply.github.com> Date: Sat, 28 Nov 2026 02:33:03 +0000 Subject: [PATCH 35/40] feat(kubectl): add `kcgetns` alias to show the current namespace (#13215) * rebase and review changes * full command in readme * space --- plugins/kubectl/README.md | 1 + plugins/kubectl/kubectl.plugin.zsh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index ffd065b6b..95ef190fd 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -60,6 +60,7 @@ plugins=(... kubectl) | | | **Namespace management** | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | kcn | `kubectl config set-context --current --namespace` | Change current namespace | +| kcgetns | `kubectl config view --minify -o jsonpath={.contexts[0].context.namespace}` | Get the current context's namespace | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 94717eda7..d19ab07b4 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -31,7 +31,7 @@ alias kapk='kubectl apply -k' # Drop into an interactive terminal on a container alias keti='kubectl exec -t -i' -# Manage configuration quickly to switch contexts between local, dev ad staging. +# Manage configuration quickly to switch contexts between local, dev and staging. alias kcuc='kubectl config use-context' alias kcsc='kubectl config set-context' alias kcdc='kubectl config delete-context' @@ -83,6 +83,7 @@ alias kens='kubectl edit namespace' alias kdns='kubectl describe namespace' alias kdelns='kubectl delete namespace' alias kcn='kubectl config set-context --current --namespace' +alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'" # ConfigMap management alias kgcm='kubectl get configmaps' From e7a67d2e80e833c478aa8b2d17b7cf4a18cabe40 Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Sat, 28 Nov 2026 03:34:48 +0100 Subject: [PATCH 36/40] ci: add alias collision check (#10859) * first draft alias collision * add collision check to github actions * run python unit tests in CI * update actions to latest major version * rename test to tests * improve error message * print all collisions found before failing * disable failing of collision checker temporarily * fix CI * refactor to pytest * add filter for known collisions * read known collisions from file * removed resolved collision * remove known collisions * better use checkout * explicitly use master * fix plugin path * move tool to .github workflows * review comments * pin actions --- .github/workflows/alias_collision/.gitignore | 2 + .../alias_collision/check_alias_collision.py | 170 ++++++++++++++++++ .../alias_collision/requirements.txt | 2 + .../tests/test_check_alias_collision.py | 166 +++++++++++++++++ .github/workflows/main.yml | 28 +++ 5 files changed, 368 insertions(+) create mode 100644 .github/workflows/alias_collision/.gitignore create mode 100644 .github/workflows/alias_collision/check_alias_collision.py create mode 100644 .github/workflows/alias_collision/requirements.txt create mode 100644 .github/workflows/alias_collision/tests/test_check_alias_collision.py diff --git a/.github/workflows/alias_collision/.gitignore b/.github/workflows/alias_collision/.gitignore new file mode 100644 index 000000000..300ea639b --- /dev/null +++ b/.github/workflows/alias_collision/.gitignore @@ -0,0 +1,2 @@ +# default known collisions file +known_collisions.json diff --git a/.github/workflows/alias_collision/check_alias_collision.py b/.github/workflows/alias_collision/check_alias_collision.py new file mode 100644 index 000000000..69c5ad10a --- /dev/null +++ b/.github/workflows/alias_collision/check_alias_collision.py @@ -0,0 +1,170 @@ +"""Check for alias collisions within the codebase""" + +from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser +from pathlib import Path +from dataclasses import dataclass +import itertools +import re +import json +import sys + + +ERROR_MESSAGE_TEMPLATE = ( + "Alias `%s` defined in `%s` already exists as alias `%s` in `%s`." +) + +KNOWN_COLLISIONS_PATH = Path(__file__).resolve().parent / "known_collisions.json" + + +def dir_path(path_string: str) -> Path: + if Path(path_string).is_dir(): + return Path(path_string) + else: + raise NotADirectoryError(path_string) + + +def parse_arguments(): + parser = ArgumentParser( + description=__doc__, + formatter_class=ArgumentDefaultsHelpFormatter, + ) + parser.add_argument( + "folder", + type=dir_path, + help="Folder to check", + ) + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument( + "--known-collisions", + type=Path, + default=None, + help="Json-serialized list of known collision to compare to", + ) + group.add_argument( + "--known-collisions-output-path", + type=Path, + default=KNOWN_COLLISIONS_PATH, + help="Output path for a json-serialized list of known collisions", + ) + return parser.parse_args() + + +@dataclass(frozen=True) +class Alias: + alias: str + value: str + module: Path + + def to_dict(self) -> dict: + return { + "alias": self.alias, + "value": self.value, + "module": str(self.module), + } + + +@dataclass(frozen=True) +class Collision: + existing_alias: Alias + new_alias: Alias + + def is_new_collision(self, known_collision_aliases: list[str]) -> bool: + return self.new_alias.alias not in known_collision_aliases + + @classmethod + def from_dict(cls, collision_dict: dict) -> "Collision": + return cls( + Alias(**collision_dict["existing_alias"]), + Alias(**collision_dict["new_alias"]), + ) + + def to_dict(self) -> dict: + return { + "existing_alias": self.existing_alias.to_dict(), + "new_alias": self.new_alias.to_dict(), + } + + +def find_aliases_in_file(file: Path) -> list[Alias]: + matches = re.findall( + r"^[ \t]*alias (?:-[gs] )?([^ =]+)=['\"]?(.*?)['\"]?$", + file.read_text(), + re.MULTILINE, + ) + return [Alias(match[0], match[1], file) for match in matches] + + +def load_known_collisions(collision_file: Path) -> list[Collision]: + collision_list = json.loads(collision_file.read_text()) + return [Collision.from_dict(collision_dict) for collision_dict in collision_list] + + +def find_all_aliases(path: Path) -> list: + aliases = [find_aliases_in_file(file) for file in path.rglob("*.zsh")] + return list(itertools.chain(*aliases)) + + +def check_for_duplicates(aliases: list[Alias]) -> list[Collision]: + elements = {} + collisions = [] + for alias in aliases: + if alias.alias in elements: + existing = elements[alias.alias] + collisions.append(Collision(existing, alias)) + else: + elements[alias.alias] = alias + return collisions + + +def print_collisions(collisions: dict[Alias, Alias]) -> None: + if collisions: + print(f"Found {len(collisions)} alias collisions:\n") + for collision in collisions: + print( + ERROR_MESSAGE_TEMPLATE + % ( + f"{collision.new_alias.alias}={collision.new_alias.value}", + collision.new_alias.module.name, + f"{collision.existing_alias.alias}={collision.existing_alias.value}", + collision.existing_alias.module.name, + ) + ) + print("\nConsider renaming your aliases.") + else: + print("Found no collisions") + + +def check_for_new_collisions( + known_collisions: Path, collisions: list[Collision] +) -> list[Collision]: + known_collisions = load_known_collisions(known_collisions) + known_collision_aliases = [ + collision.new_alias.alias for collision in known_collisions + ] + + return [ + collision + for collision in collisions + if collision.is_new_collision(known_collision_aliases) + ] + + +def main() -> int: + """main""" + args = parse_arguments() + aliases = find_all_aliases(args.folder) + collisions = check_for_duplicates(aliases) + + if args.known_collisions is not None: + new_collisions = check_for_new_collisions(args.known_collisions, collisions) + print_collisions(new_collisions) + return -1 if new_collisions else 0 + + args.known_collisions_output_path.write_text( + json.dumps([collision.to_dict() for collision in collisions]) + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/workflows/alias_collision/requirements.txt b/.github/workflows/alias_collision/requirements.txt new file mode 100644 index 000000000..0641680db --- /dev/null +++ b/.github/workflows/alias_collision/requirements.txt @@ -0,0 +1,2 @@ +pyfakefs +pytest diff --git a/.github/workflows/alias_collision/tests/test_check_alias_collision.py b/.github/workflows/alias_collision/tests/test_check_alias_collision.py new file mode 100644 index 000000000..c6a3802ee --- /dev/null +++ b/.github/workflows/alias_collision/tests/test_check_alias_collision.py @@ -0,0 +1,166 @@ +from pathlib import Path + +from pyfakefs.fake_filesystem import FakeFilesystem +import pytest + +from check_alias_collision import ( + dir_path, + find_all_aliases, + find_aliases_in_file, + check_for_duplicates, + Alias, + Collision, + load_known_collisions, +) + + +THREE_ALIASES = """ +alias g='git' + +alias ga='git add' +alias gaa='git add --all' +""" + +CONDITIONAL_ALIAS = """ +is-at-least 2.8 "$git_version" \ + && alias gfa='git fetch --all --prune --jobs=10' \ + || alias gfa='git fetch --all --prune' +""" + +ONE_KNOWN_COLLISION = """ +[ + { + "existing_alias": { + "alias": "gcd", + "value": "git checkout $(git_develop_branch)", + "module": "plugins/git/git.plugin.zsh" + }, + "new_alias": { + "alias": "gcd", + "value": "git checkout $(git config gitflow.branch.develop)", + "module": "plugins/git-flow/git-flow.plugin.zsh" + } + } +] +""" + + +def test_dir_path__is_dir__input_path(fs: FakeFilesystem) -> None: + fs.create_dir("test") + assert Path("test") == dir_path("test") + + +def test_dir_path__is_file__raise_not_a_directory_error(fs: FakeFilesystem) -> None: + fs.create_file("test") + with pytest.raises(NotADirectoryError): + dir_path("test") + + +def test_dir_path__does_not_exist__raise_not_a_directory_error( + fs: FakeFilesystem, +) -> None: + with pytest.raises(NotADirectoryError): + dir_path("test") + + +def test_find_all_aliases__empty_folder_should_return_empty_list( + fs: FakeFilesystem, +) -> None: + fs.create_dir("test") + result = find_all_aliases(Path("test")) + assert [] == result + + +def test_find_aliases_in_file__empty_text_should_return_empty_list( + fs: FakeFilesystem, +) -> None: + fs.create_file("empty.zsh") + result = find_aliases_in_file(Path("empty.zsh")) + assert [] == result + + +def test_find_aliases_in_file__one_alias_should_find_one(fs: FakeFilesystem) -> None: + fs.create_file("one.zsh", contents="alias g='git'") + result = find_aliases_in_file(Path("one.zsh")) + assert [Alias("g", "git", Path("one.zsh"))] == result + + +def test_find_aliases_in_file__three_aliases_should_find_three( + fs: FakeFilesystem, +) -> None: + fs.create_file("three.zsh", contents=THREE_ALIASES) + result = find_aliases_in_file(Path("three.zsh")) + assert [ + Alias("g", "git", Path("three.zsh")), + Alias("ga", "git add", Path("three.zsh")), + Alias("gaa", "git add --all", Path("three.zsh")), + ] == result + + +def test_find_aliases_in_file__one_conditional_alias_should_find_none( + fs: FakeFilesystem, +) -> None: + fs.create_file("conditional.zsh", contents=CONDITIONAL_ALIAS) + result = find_aliases_in_file(Path("conditional.zsh")) + assert [] == result + + +def test_check_for_duplicates__no_duplicates_should_return_empty_dict() -> None: + result = check_for_duplicates( + [ + Alias("g", "git", Path("git.zsh")), + Alias("ga", "git add", Path("git.zsh")), + Alias("gaa", "git add --all", Path("git.zsh")), + ] + ) + assert result == [] + + +def test_check_for_duplicates__duplicates_should_have_one_collision() -> None: + result = check_for_duplicates( + [ + Alias("gc", "git commit", Path("git.zsh")), + Alias("gc", "git clone", Path("git.zsh")), + ] + ) + assert result == [ + Collision( + Alias("gc", "git commit", Path("git.zsh")), + Alias("gc", "git clone", Path("git.zsh")), + ) + ] + + +def test_is_new_collision__new_alias_not_in_known_collisions__should_return_true() -> ( + None +): + known_collisions = ["gc", "gd"] + new_alias = Alias("ga", "git add", Path("git.zsh")) + collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias) + assert collision.is_new_collision(known_collisions) is True + + +def test_is_new_collision__new_alias_in_known_collisions__should_return_false() -> None: + known_collisions = ["gc", "gd", "ga"] + new_alias = Alias("ga", "git add", Path("git.zsh")) + collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias) + assert collision.is_new_collision(known_collisions) is False + + +def test_load_known_collisions__empty_file__should_return_empty_list( + fs: FakeFilesystem, +) -> None: + empty_list = Path("empty.json") + fs.create_file(empty_list, contents="[]") + result = load_known_collisions(empty_list) + assert [] == result + + +def test_load_known_collisions__one_collision__should_return_one_collision( + fs: FakeFilesystem, +) -> None: + known_collisions_file = Path("known_collisions.json") + fs.create_file(known_collisions_file, contents=ONE_KNOWN_COLLISION) + result = load_known_collisions(known_collisions_file) + assert 1 == len(result) + assert "gcd" == result[0].existing_alias.alias diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 617f23674..7f4392270 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,3 +41,31 @@ jobs: ./themes/*.zsh-theme; do zsh -n "$file" || return 1 done + + collisions: + name: Check alias collisions + runs-on: ubuntu-latest + steps: + - name: Set up git repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: '3.14' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .github/workflows/alias_collision/requirements.txt + - name: Run unit tests + run: | + cd .github/workflows/alias_collision/ + python -m pytest + - name: Checkout target branch + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: ohmyzsh-target-branch + ref: master + - name: Check for alias collisions on target branch + run: python .github/workflows/alias_collision/check_alias_collision.py ohmyzsh-target-branch/plugins --known-collisions-output-path known_alias_collisions.json + - name: Compare known collisions to new collisions on source branch + run: python .github/workflows/alias_collision/check_alias_collision.py plugins --known-collisions known_alias_collisions.json From 801782e8a62ca06612c2ac1659ead1e3c138e4bc Mon Sep 17 00:00:00 2001 From: Tien Nguyen Minh Date: Sat, 28 Nov 2026 09:54:18 +0700 Subject: [PATCH 37/40] fix(spectrum): fall back to a loop on zsh older than 5.0.6 (#14278) --- lib/spectrum.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index 86a939e8a..99573beee 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -2,6 +2,8 @@ # P.C. Shyamshankar # Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ +autoload -Uz is-at-least + typeset -AHg FX FG BG FX=( @@ -18,7 +20,16 @@ FX=( () { setopt localoptions noksharrays local -a codes fg bg + local code codes=({000..255}) + # ${a:^b} array zipping needs zsh 5.0.6 + if ! is-at-least 5.0.6; then + for code in $codes; do + FG[$code]="%{"$'\e'"[38;5;${code}m%}" + BG[$code]="%{"$'\e'"[48;5;${code}m%}" + done + return + fi fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" ) bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" ) FG=( ${codes:^fg} ) From 90f9fbc532c8c4f38099602bd9759da0aabe8fa4 Mon Sep 17 00:00:00 2001 From: Abdullah Ahmed Date: Fri, 27 Nov 2026 22:01:52 -0500 Subject: [PATCH 38/40] feat(terraform): add terraform-docs completion (#14185) Generate completions from the installed terraform-docs CLI in the background and preserve a valid cache when generation fails or returns no output. Fixes #12138 AI-assisted with OpenAI Codex. --- plugins/terraform/README.md | 8 ++++++++ plugins/terraform/terraform.plugin.zsh | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index 711139ef0..ec5253908 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -12,6 +12,14 @@ plugins=(... terraform) ## Requirements - [Terraform](https://terraform.io/) +- [terraform-docs](https://terraform-docs.io/) (optional, for completion) + +## terraform-docs completion + +If `terraform-docs` is installed, this plugin also enables its completion. +The completion script is generated from the installed version and cached in +`$ZSH_CACHE_DIR/completions/_terraform-docs`. It is refreshed in the background +each time the plugin loads, so completion stays in sync with the installed CLI. ## Aliases diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index 8e57b00db..bfa1494db 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -39,3 +39,23 @@ alias tfsh='terraform show' alias tfw='terraform workspace' alias tfwl='terraform workspace list' alias tfws='terraform workspace select' + +if (( $+commands[terraform-docs] )); then + # If the completion file doesn't exist yet, compinit hasn't registered it. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_terraform-docs" ]]; then + typeset -g -A _comps + autoload -Uz _terraform-docs + _comps[terraform-docs]=_terraform-docs + fi + + zmodload -F zsh/files b:zf_mv + () { + local completions + completions=$(command terraform-docs completion zsh) || return + [[ -n "$completions" ]] || return + + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._terraform-docs" + zf_mv -f -- =(print -r -- "$completions") \ + "$ZSH_CACHE_DIR/completions/_terraform-docs" + } &| +fi From 44a5decbc48c4f1885c754eb2044d09a466e4187 Mon Sep 17 00:00:00 2001 From: Calion Date: Fri, 27 Nov 2026 21:23:33 -0600 Subject: [PATCH 39/40] docs(thefuck): put the plugins line in a code block (#13272) Added copybox for plugin code --- plugins/thefuck/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md index 84f7255ce..b8dd87d0f 100644 --- a/plugins/thefuck/README.md +++ b/plugins/thefuck/README.md @@ -4,7 +4,9 @@ To use it, add thefuck to the plugins array of your zshrc file: +```zsh plugins=(... thefuck) +``` ## Usage Press `ESC` twice to correct previous console command. From e0fb74a8e229d63ad74f27f15dec8d93f2b64fee Mon Sep 17 00:00:00 2001 From: YourNeelsOG Date: Sun, 29 Nov 2026 03:55:09 +0600 Subject: [PATCH 40/40] fix(vi-mode): restore cursor shape when leaving visual mode (#14313) Fixes #11705 --- plugins/vi-mode/vi-mode.plugin.zsh | 32 ++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 7c057b788..fa8afa0b8 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -43,12 +43,32 @@ function _vi-mode-set-cursor-shape-for-keymap() { printf $'\e[%d q' "${_shape}" } -function _visual-mode { - typeset -g VI_KEYMAP=visual - _vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP" - zle .visual-mode -} -zle -N visual-mode _visual-mode +autoload -Uz is-at-least +if is-at-least 5.3; then + # Visual mode doesn't change $KEYMAP, it only activates the region, so + # zle-keymap-select never runs when it starts or ends + function _vi-mode-zle-line-pre-redraw() { + if [[ "$KEYMAP" = vicmd ]] && (( REGION_ACTIVE )); then + [[ "$VI_KEYMAP" != visual ]] || return 0 + typeset -g VI_KEYMAP=visual + elif [[ "$VI_KEYMAP" = visual ]]; then + typeset -g VI_KEYMAP=$KEYMAP + else + return 0 + fi + _vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP" + } + autoload -Uz add-zle-hook-widget + add-zle-hook-widget zle-line-pre-redraw _vi-mode-zle-line-pre-redraw +else + # zle-line-pre-redraw needs zsh 5.3 + function _visual-mode { + typeset -g VI_KEYMAP=visual + _vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP" + zle .visual-mode + } + zle -N visual-mode _visual-mode +fi function _vi-mode-should-reset-prompt() { # If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset (default), dynamically