Skip to content

Commit 048e166

Browse files
authored
feat(z): update to dd94ef04 (ohmyzsh#12862)
Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
1 parent b9e73b4 commit 048e166

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

.github/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies:
3636
plugins/z:
3737
branch: master
3838
repo: agkozak/zsh-z
39-
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
39+
version: dd94ef04acc41748ba171eb219971cb455e0040b
4040
precopy: |
4141
set -e
4242
test -e README.md && mv -f README.md MANUAL.md

plugins/z/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2023 Alexandros Kozak
3+
Copyright (c) 2018-2024 Alexandros Kozak
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

plugins/z/MANUAL.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
![Zsh-z demo](img/demo.gif)
88

9-
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`.
9+
Zsh-z is a command-line tool that allows you to jump quickly to directories that you have visited frequently or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. Based on this data, it predicts where you want to go when you type a partial string. For example, `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how long you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need to if you were using `cd`.
1010

11-
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
11+
Zsh-z is a native Zsh port of [`rupa/z`](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. `rupa/z` was my most used command-line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
1212

13-
There is a noteworthy stability increase as well. Race conditions have always been a problem with `rupa/z`, and users of that utility will occasionally lose their `.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database, even through extreme testing.
13+
There is also a significant stability improvement. Race conditions have always been a problem with `rupa/z`, and users of that utility occasionally lose their `~/.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code standard that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database.
1414

15-
There are other, smaller improvements which I try to document in [Improvements and Fixes](#improvements-and-fixes). These include the new default behavior of sorting your tab completions by frecency rather than just letting Zsh sort the raw results alphabetically (a behavior which can be restored if you like it -- [see below](#settings)).
15+
There are other, smaller improvements which I document below in [Improvements and Fixes](#improvements-and-fixes). For instance, tab completions are now sorted by frecency by default rather than alphabetically (the latter behavior can be restored if you like it -- [see below](#settings)).
1616

17-
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`), so you can go on using `rupa/z` when you launch `bash`.
17+
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`, or whatever database file you specify), so you can go on using `rupa/z` when you launch `bash`.
1818

1919
## Table of Contents
2020
- [News](#news)
@@ -37,13 +37,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
3737
- August 24, 2023
3838
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
3939
- August 23, 2023
40-
+ Better logic for loading `zsh/files` (props @z0rc)
40+
+ Better logic for loading `zsh/files` (props @z0rc).
4141
- August 2, 2023
42-
+ Zsh-z still uses the `zsh/files` module when possible, but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
42+
+ Zsh-z still uses the `zsh/files` module when possible but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
4343
- April 27, 2023
4444
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
4545
- January 27, 2023
46-
+ If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
46+
+ If the database file directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
4747
- June 29, 2022
4848
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
4949
- June 27, 2022
@@ -69,7 +69,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
6969
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
7070
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
7171
- July 29, 2021
72-
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings.
72+
+ Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
7373
- July 27, 2021
7474
+ Internal escaping of path names now works with older versions of ZSH.
7575
+ Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
@@ -102,7 +102,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
102102
- December 22, 2020
103103
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
104104
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
105-
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed.
105+
+ Symlinked database files were having their symlinks overwritten; this bug has been fixed.
106106

107107
</details>
108108

@@ -118,7 +118,7 @@ For tab completion to work, `_zshz` *must* be in the same directory as `zsh-z.pl
118118

119119
autoload -U compinit; compinit
120120

121-
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`.
121+
in your `.zshrc` somewhere below where you source `zsh-z.plugin.zsh`.
122122

123123
If you add
124124

@@ -188,7 +188,7 @@ Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
188188
Then relaunch `zsh`.
189189

190190
### For [zcomet](https://github.com/agkozak/zcomet) users
191-
191+
192192
Simply add
193193

194194
zcomet load agkozak/zsh-z
@@ -228,7 +228,7 @@ Add the line
228228

229229
to your `.zshrc`.
230230

231-
`zsh-z` supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zshz` to restore the shell to its state before `zsh-z` was loaded.
231+
Zsh-z supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zsh-z` to restore the shell to its state before Zsh-z was loaded.
232232

233233
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
234234

@@ -249,7 +249,7 @@ somewhere above the line that says `zplug load`. Then run
249249
zplug install
250250
zplug load
251251

252-
to install `zsh-z`.
252+
to install Zsh-z.
253253

254254
## Command Line Options
255255

@@ -263,9 +263,9 @@ to install `zsh-z`.
263263
- `-x` Remove a directory (by default, the current directory) from the database
264264
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
265265

266-
# Settings
266+
## Settings
267267

268-
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`).
268+
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them. You can also keep your old ones if you have been using `rupa/z` (whose environment variables begin with `_Z_`).
269269

270270
* `ZSHZ_CMD` changes the command name (default: `z`)
271271
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
@@ -324,19 +324,18 @@ A good example might involve a directory tree that has Git repositories within i
324324

325325
(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.)
326326

327-
328327
## Other Improvements and Fixes
329328

330329
* `z -x` works, with the help of `chpwd_functions`.
331-
* Zsh-z works on Solaris.
330+
* Zsh-z is compatible with Solaris.
332331
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
333-
* There is no error message when the database file has not yet been created.
334-
* There is support for special characters (e.g., `[`) in directory names.
335-
* If `z -l` only returns one match, a common root is not printed.
336-
* Exit status codes increasingly make sense.
337-
* Completions work with options `-c`, `-r`, and `-t`.
338-
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root.
339-
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database.
332+
* No error message is displayed when the database file has not yet been created.
333+
* Special characters (e.g., `[`) in directory names are now supported.
334+
* If `z -l` returns only one match, a common root is not printed.
335+
* Exit status codes are more logical.
336+
* Completions now work with options `-c`, `-r`, and `-t`.
337+
* If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
338+
* `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.
340339

341340
## Migrating from Other Tools
342341

@@ -358,7 +357,7 @@ the line
358357

359358
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
360359

361-
## Known Bugs
360+
## Known Bug
362361
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
363362

364363
z us /usr/local/bin.

plugins/z/z.plugin.zsh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# https://github.com/agkozak/zsh-z
66
#
7-
# Copyright (c) 2018-2023 Alexandros Kozak
7+
# Copyright (c) 2018-2024 Alexandros Kozak
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal
@@ -120,7 +120,6 @@ fi
120120
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
121121
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
122122

123-
124123
# Load zsh/system, if necessary
125124
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
126125

0 commit comments

Comments
 (0)