d50115afd60ea93369c1f3c32302b7482e7369d4
- Author
- ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.github/dependencies.yml b/.github/dependencies.yml
2index ff239c657e6cea7c275dd7fe73b7e615f9cdac9d..7794e3346a69ca56a1b0ff56f9739d2674d9ab4f 100644
3--- a/.github/dependencies.yml
4+++ b/.github/dependencies.yml
5@@ -46,7 +46,7 @@ dependencies:
6 plugins/z:
7 branch: master
8 repo: agkozak/zsh-z
9- version: cf9225feebfae55e557e103e95ce20eca5eff270
10+ version: ae10ba3f4674c24ac353fd34deb2fd9f7b061055
11 precopy: |
12 set -e
13 test -e README.md && mv -f README.md MANUAL.md
14diff --git a/plugins/z/LICENSE b/plugins/z/LICENSE
15index b36aeb40845a699bc358a3cdcc9d1ab079d99a6b..8befb303b8c5c5060061f410bb5022d70e62e7de 100644
16--- a/plugins/z/LICENSE
17+++ b/plugins/z/LICENSE
18@@ -1,6 +1,6 @@
19 MIT License
20
21-Copyright (c) 2018-2025 Alexandros Kozak
22+Copyright (c) 2018-2026 Alexandros Kozak
23
24 Permission is hereby granted, free of charge, to any person obtaining a copy
25 of this software and associated documentation files (the "Software"), to deal
26diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md
27index eddf787dd2dba77a0ba80b82817a1277867aa80b..9984d3b1f3d7b6deebb2491db153546cf95d550c 100644
28--- a/plugins/z/MANUAL.md
29+++ b/plugins/z/MANUAL.md
30@@ -24,16 +24,18 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
31 - [Case Sensitivity](#case-sensitivity)
32 - [`ZSHZ_UNCOMMON`](#zshz_uncommon)
33 - [Making `--add` work for you](#making---add-work-for-you)
34-- [Other Improvements and Fixes](#other-improvements-and-fixes)
35+- [Other Improvements to the Original Functionality of `rupa/z`](#other-improvements-to-the-original-functionality-of-rupa-z)
36 - [Migrating from Other Tools](#migrating-from-other-tools)
37 - [`COMPLETE_ALIASES`](#complete_aliases)
38-- [Known Bugs](#known-bugs)
39
40 ## News
41
42 <details>
43 <summary>Here are the latest features and updates.</summary>
44
45+- March 31, 2026
46+ + When the user hits Tab after entering a command-line argument that uses spaces as wildcards (e.g., `z us lo bi`), the command line is clear of detritus (i.e., it looks like `z /usr/local/bin` instead of `z us lo /usr/local/bin`).
47+ + Improved test for Docker containers.
48 - August 24, 2023
49 + Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
50 - August 23, 2023
51@@ -50,7 +52,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
52 + A bug was fixed which was preventing paths with spaces in them from being updated ([#61](https://github.com/agkozak/zsh-z/issues/61)).
53 + If writing to the temporary database file fails, the database will not be clobbered (props @mafredri).
54 - December 19, 2021
55- + ZSH-z will now display tildes for `HOME` during completion when `ZSHZ_TILDE=1` has been set.
56+ + Zsh-z will now display tildes for `HOME` during completion when `ZSHZ_TILDE=1` has been set.
57 - November 11, 2021
58 + A bug was fixed which was preventing ranks from being incremented.
59 + `--add` has been made to work with relative paths and has been documented for the user.
60@@ -71,7 +73,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
61 - July 29, 2021
62 + Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
63 - July 27, 2021
64- + Internal escaping of path names now works with older versions of ZSH.
65+ + Internal escaping of path names now works with older versions of Zsh.
66 + Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
67 - July 10, 2021
68 + Setting `ZSHZ_TRAILING_SLASH=1` makes it so that a search pattern ending in `/` can match the end of a path; e.g. `z foo/` can match `/path/to/foo`.
69@@ -79,12 +81,12 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
70 + Setting `ZSHZ_TILDE=1` displays the `HOME` directory as `~`.
71 - May 7, 2021
72 + Setting `ZSHZ_ECHO=1` will cause Zsh-z to display the new path when you change directories.
73- + Better escaping of path names to deal paths containing the characters ``\`()[]``.
74+ + Better escaping of path names to deal with paths containing the characters ``\`()[]``.
75 - February 15, 2021
76 + Ranks are displayed the way `rupa/z` now displays them, i.e. as large integers. This should help Zsh-z to integrate with other tools.
77 - January 31, 2021
78 + Zsh-z is now efficient enough that, on MSYS2 and Cygwin, it is faster to run it in the foreground than it is to fork a subshell for it.
79- + `_zshz_precmd` simply returns if `PWD` is `HOME` or in `ZSH_EXCLUDE_DIRS`, rather than waiting for `zshz` to do that.
80+ + `_zshz_precmd` simply returns if `PWD` is `HOME` or in `ZSHZ_EXCLUDE_DIRS`, rather than waiting for `zshz` to do that.
81 - January 17, 2021
82 + Made sure that the `PUSHD_IGNORE_DUPS` option is respected.
83 - January 14, 2021
84@@ -171,7 +173,7 @@ is uncommented. Then find the section that specifies which modules are to be loa
85 'completion' \
86 'prompt'
87
88-Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
89+Add a backslash to the end of the last line and add `'zsh-z'` to the list, e.g.,
90
91 zstyle ':prezto:load' pmodule \
92 'environment' \
93@@ -279,7 +281,7 @@ Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its be
94 * `ZSHZ_OWNER` allows usage when in `sudo -s` mode (default: empty)
95 * `ZSHZ_TILDE` displays the name of the `HOME` directory as a `~` (default: `0`)
96 * `ZSHZ_TRAILING_SLASH` makes it so that a search pattern ending in `/` can match the final element in a path; e.g., `z foo/` can match `/path/to/foo` (default: `0`)
97-* `ZSHZ_UNCOMMON` changes the logic used to calculate the directory jumped to; [see below](#zshz_uncommon`) (default: `0`)
98+* `ZSHZ_UNCOMMON` changes the logic used to calculate the directory jumped to; [see below](#zshz_uncommon) (default: `0`)
99
100 ## Case sensitivity
101
102@@ -324,7 +326,7 @@ A good example might involve a directory tree that has Git repositories within i
103
104 (As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
105
106-## Other Improvements and Fixes
107+## Other Improvements to the Original Functionality of `rupa/z`
108
109 * `z -x` works, with the help of `chpwd_functions`.
110 * Zsh-z is compatible with Solaris.
111@@ -336,6 +338,7 @@ A good example might involve a directory tree that has Git repositories within i
112 * Completions now work with options `-c`, `-r`, and `-t`.
113 * If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
114 * `z -x` and the new, recursive `z -xR` can now accept an argument so that you can remove directories other than `PWD` from the database.
115+* Zsh-z inherits `rupa/z`'s behavior of allowing spaces as wildcards (e.g., `z us lo bi` might take you to `/usr/local/bin`), but now completion of such command lines does not result in visual detritus.
116
117 ## Migrating from Other Tools
118
119@@ -347,7 +350,7 @@ If you are coming to Zsh-z (or even to the original `rupa/z`, for that matter) f
120
121 ## `COMPLETE_ALIASES`
122
123diff --git a/plugins/z/_z b/plugins/z/_z
124index a493f35bade0096449e28708afa8f82794a8dc71..a109841d6260c7e1bcb0e1dbd8ef866976a0da54 100644
125--- a/plugins/z/_z
126+++ b/plugins/z/_z
127@@ -5,7 +5,7 @@
128 #
129 # https://github.com/agkozak/zsh-z
130 #
131-# Copyright (c) 2018-2023 Alexandros Kozak
132+# Copyright (c) 2018-2026 Alexandros Kozak
133 #
134 # Permission is hereby granted, free of charge, to any person obtaining a copy
135 # of this software and associated documentation files (the "Software"), to deal
136@@ -37,25 +37,10 @@ emulate -L zsh
137 (( ZSHZ_DEBUG )) &&
138 setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
139
140-# TODO: This routine currently reproduces z's feature of allowing spaces to be
141-# used as wildcards in completions, so that
142-#
143-# z us lo bi
144-#
145-# can expand to
146-#
147-# z /usr/local/bin
148-#
149-# but it also reproduces z's buggy display on the commandline, viz.
150-#
151-# z us lo /usr/local/bin
152-#
153-# Address.
154-
155 local completions expl completion
156 local -a completion_list
157
158-completions=$(zshz --complete ${(@)words:1})
159+completions=$(zshz --complete "${(@)words:1}")
160 [[ -z $completions ]] && return 1
161
162 for completion in ${(f)completions[@]}; do
163diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh
164index 39b832292eb887627fc53c21f46399d0ae9d81e9..456802d3d373b21805158cb274fe77325636db56 100644
165--- a/plugins/z/z.plugin.zsh
166+++ b/plugins/z/z.plugin.zsh
167@@ -4,7 +4,7 @@
168 #
169 # https://github.com/agkozak/zsh-z
170 #
171-# Copyright (c) 2018-2025 Alexandros Kozak
172+# Copyright (c) 2018-2026 Alexandros Kozak
173 #
174 # Permission is hereby granted, free of charge, to any person obtaining a copy
175 # of this software and associated documentation files (the "Software"), to deal
176@@ -294,9 +294,9 @@ zshz() {
177 owner=${ZSHZ_OWNER:-${_Z_OWNER}}
178
179 if (( ZSHZ[USE_FLOCK] )); then
180- # An unsual case: if inside Docker container where datafile could be bind
181+ # An unusual case: if inside Docker container where datafile could be bind
182 # mounted
183- if [[ -r '/proc/1/cgroup' && "$(< '/proc/1/cgroup')" == *docker* ]]; then
184+ if [[ -f '/.dockerenv' || ( -r '/proc/1/cgroup' && "$(< '/proc/1/cgroup')" == *docker* ) ]]; then
185 print "$(< "$tempfile")" > "$datafile" 2> /dev/null
186 ${ZSHZ[RM]} -f "$tempfile"
187 # All other cases
188@@ -960,6 +960,62 @@ add-zsh-hook chpwd _zshz_chpwd
189
190 (( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" )
191
192+# Save the existing Tab binding
193+ZSHZ[TAB_BINDING]="${$(bindkey -M main '^I')##* }"
194+
195+############################################################
196+# ZLE widget to fix spaces-as-wildcards completion
197+#
198+# When completing a Zsh-z command with multiple search terms
199+# (e.g. `z us lo bi'), collapse the terms into a single
200+# wildcard-joined word (e.g. `z us*lo*bi') before triggering
201+# completion. This causes compadd to replace the whole query
202+# with the matched path rather than just the last word.
203+#
204+# Globals:
205+# ZSHZ_CMD
206+############################################################
207+_zshz_zle_completion_widget() {
208+ emulate -L zsh
209+ local cmd=${ZSHZ_CMD:-${_Z_CMD:-z}}
210+
211+ # If a trailing space was added after an already-completed absolute path
212+ # (e.g. `z /usr/local/bin '), a second Tab would otherwise re-trigger
213+ # completion on an empty word and insert a duplicate. Bail out early.
214+ if [[ $LBUFFER[-1] == ' ' && ${${LBUFFER% }##* } == [/~]* ]]; then
215+ return
216+ fi
217+
218+ # Only act when there are at least two words after the command
219+ if [[ $LBUFFER == ${cmd}\ *\ * ]]; then
220+ local after=${LBUFFER#${cmd} }
221+ local -a parts flag_parts search_parts
222+ local p past_flags=0
223+
224+ parts=( ${(z)after} )
225+ for p in $parts; do
226+ if (( ! past_flags )) && [[ $p == -[cehlrRtx]## ]]; then
227+ flag_parts+=( $p )
228+ else
229+ past_flags=1
230+ search_parts+=( $p )
231+ fi
232+ done
233+
234+ if (( ${#search_parts} > 1 )); then
235+ LBUFFER="${cmd}${flag_parts:+ ${(j: :)flag_parts}} ${(j:*:)search_parts}"
236+ fi
237+ fi
238+
239+ # If Tab had a non-default binding, continue to use it; otherwise the default
240+ # expand-or-complete gets used.
241+ zle ${ZSHZ[TAB_BINDING]:-expand-or-complete}
242+}
243+
244+zle -N _zshz_zle_completion_widget
245+
246+bindkey -M main '^I' _zshz_zle_completion_widget
247+
248 ############################################################
249 # zsh-z functions
250 ############################################################
251@@ -974,7 +1030,8 @@ ZSHZ[FUNCTIONS]='_zshz_usage
252 zshz
253 _zshz_precmd
254 _zshz_chpwd
255- _zshz'
256+ _zshz
257+ _zshz_zle_completion_widget'
258
259 ############################################################
260 # Enable WARN_NESTED_VAR for functions listed in
261@@ -1004,6 +1061,16 @@ zsh-z_plugin_unload() {
262 add-zsh-hook -D precmd _zshz_precmd
263 add-zsh-hook -d chpwd _zshz_chpwd
264
265+ zle -D _zshz_zle_completion_widget
266+