Compare commits

..

1 Commits

Author SHA1 Message Date
Andrew Babichev 4fae3334e6
Merge 53ad1e3bac into b9e73b4481 2024-12-17 14:12:29 +01:00
17 changed files with 53 additions and 121 deletions

View File

@ -2,13 +2,11 @@ dependencies:
plugins/gitfast:
repo: felipec/git-completion
branch: master
version: tag:v2.2
version: tag:v2.1
postcopy: |
set -e
rm -rf git-completion.plugin.zsh Makefile t tools
mv README.adoc MANUAL.adoc
mv -f src/* .
rmdir src
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
test -e git-completion.zsh && mv -f git-completion.zsh _git
plugins/gradle:
repo: gradle/gradle-completion
branch: master
@ -38,7 +36,7 @@ dependencies:
plugins/z:
branch: master
repo: agkozak/zsh-z
version: dd94ef04acc41748ba171eb219971cb455e0040b
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
precopy: |
set -e
test -e README.md && mv -f README.md MANUAL.md

View File

@ -1,7 +1,7 @@
certifi==2024.12.14
charset-normalizer==3.4.1
charset-normalizer==3.4.0
idna==3.10
PyYAML==6.0.2
requests==2.32.3
semver==3.0.3
urllib3==2.3.0
semver==3.0.2
urllib3==2.2.3

View File

@ -1,7 +1,6 @@
#!/usr/bin/env zsh
function omz {
setopt localoptions noksharrays
[[ $# -gt 0 ]] || {
_omz::help
return 1

View File

@ -65,29 +65,6 @@ If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders
Default: `no`
### `color-scale`
```zsh
zstyle ':omz:plugins:eza' 'color-scale' all|age|size
```
Highlight levels of field(s) distinctly. Use comma(,) separated list of `all`, `age`, `size`
Default: `none`
### `color-scale-mode`
```zsh
zstyle ':omz:plugins:eza' 'color-scale-mode' gradient|fixed
```
Choose the mode for highlighting:
- `gradient` (default) -- gradient coloring
- `fixed` -- fixed coloring
Default: `gradient`
### `size-prefix`
```zsh

View File

@ -34,14 +34,6 @@ function _configure_eza() {
if zstyle -t ':omz:plugins:eza' 'icons'; then
_EZA_TAIL+=("--icons=auto")
fi
zstyle -s ':omz:plugins:eza' 'color-scale' _val
if [[ $_val ]]; then
_EZA_TAIL+=("--color-scale=$_val")
fi
zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
if [[ $_val == (gradient|fixed) ]]; then
_EZA_TAIL+=("--color-scale-mode=$_val")
fi
zstyle -s ':omz:plugins:eza' 'time-style' _val
if [[ $_val ]]; then
_EZA_TAIL+=("--time-style='$_val'")

View File

@ -1,40 +0,0 @@
This project is a friendly fork of the official Git completion
(`contrib/completion`) and prompt scripts for Bash, Zsh, and possibly other
shells.
Most Git developers use the Bash shell, for which the completion scripts work
rather well, however, Zsh is typically neglected. I've sent many patches to fix
the issues, many have been merged, but many have been ignored, thus the need for
a canonical location of a good, working Zsh completion.
There are advantages for Bash users too. Currently the scripts under `contrib` are tied to the
specific Git version, for example the completion scripts of version v2.40
(https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion/git-completion.bash?h=v2.40.0[git-completion.bash])
have issues with older versions of Git (e.g. v2.33); the ones in
this project don't.
With `git-completion` you can be sure you are using the latest completion that
works in both shells, and any Git version.
This is a sister project of the
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/gitfast[Oh My Zsh
gitfast] plugin (that I also maintain), which has similar needs.
== Installation ==
* https://github.com/felipec/git-completion/wiki/Bash[Bash instructions]
* https://github.com/felipec/git-completion/wiki/Zsh[Zsh instructions]
== Improvements from upstream ==
This is a short list of the benefits you get:
* Easier installation
* Tons of bug fixes
* Works with older versions of git
* Zsh: much more options
* Zsh: quoting works properly
* Zsh: automatic suffix removal
For a full list of all the patches on top of upstream git check
https://github.com/felipec/git-completion/wiki/Patches[Patches].

View File

@ -2,11 +2,23 @@
# zsh completion wrapper for git
#
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
# The recommended way to use this script is to prepend its location to your $fpath:
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# fpath=($git_completion_srcdir $fpath)
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
#
# You need git's bash completion script installed. By default bash-completion's
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
#
# If your bash completion script is somewhere else, you can specify the
# location in your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
zstyle -T ':completion:*:*:git:*' tag-order && \

View File

@ -1,8 +1,6 @@
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
#
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#

View File

@ -5,7 +5,6 @@ files=(
/etc/grc.zsh # default
/usr/local/etc/grc.zsh # homebrew darwin-x64
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
/home/linuxbrew/.linuxbrew/etc/grc.zsh # linuxbrew
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
)

View File

@ -22,5 +22,5 @@ fi
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
#compdef cargo
source "$(rustup run ${${(z)$(rustup default)}[1]} rustc --print sysroot)"/share/zsh/site-functions/_cargo
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
EOF

View File

@ -52,7 +52,6 @@ Available search contexts are:
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
| `chatgpt` | `https://chatgpt.com/?q=` |
| `reddit` | `https://www.reddit.com/search/?q=` |
| `ppai` | `https://www.perplexity.ai/search/new?q=` |
Also there are aliases for bang-searching DuckDuckGo:

View File

@ -33,7 +33,6 @@ function web_search() {
gopkg "https://pkg.go.dev/search?m=package&q="
chatgpt "https://chatgpt.com/?q="
reddit "https://www.reddit.com/search/?q="
ppai "https://www.perplexity.ai/search/new?q="
)
# check whether the search engine is supported
@ -88,7 +87,6 @@ alias packagist='web_search packagist'
alias gopkg='web_search gopkg'
alias chatgpt='web_search chatgpt'
alias reddit='web_search reddit'
alias ppai='web_search ppai'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018-2024 Alexandros Kozak
Copyright (c) 2018-2023 Alexandros Kozak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -6,15 +6,15 @@
![Zsh-z demo](img/demo.gif)
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`.
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`.
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`.
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`.
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.
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.
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)).
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)).
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`.
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`.
## Table of Contents
- [News](#news)
@ -37,13 +37,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
- August 24, 2023
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
- August 23, 2023
+ Better logic for loading `zsh/files` (props @z0rc).
+ Better logic for loading `zsh/files` (props @z0rc)
- August 2, 2023
+ 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.
+ 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.
- April 27, 2023
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
- January 27, 2023
+ If the database file directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
+ If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
- June 29, 2022
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
- 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
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
- July 29, 2021
+ Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings.
- July 27, 2021
+ Internal escaping of path names now works with older versions of ZSH.
+ 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
- December 22, 2020
+ `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).
+ `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).
+ Symlinked database files were having their symlinks overwritten; this bug has been fixed.
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed.
</details>
@ -118,7 +118,7 @@ For tab completion to work, `_zshz` *must* be in the same directory as `zsh-z.pl
autoload -U compinit; compinit
in your `.zshrc` somewhere below where you source `zsh-z.plugin.zsh`.
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`.
If you add
@ -188,7 +188,7 @@ Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
Then relaunch `zsh`.
### For [zcomet](https://github.com/agkozak/zcomet) users
Simply add
zcomet load agkozak/zsh-z
@ -228,7 +228,7 @@ Add the line
to your `.zshrc`.
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.
`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.
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
@ -249,7 +249,7 @@ somewhere above the line that says `zplug load`. Then run
zplug install
zplug load
to install Zsh-z.
to install `zsh-z`.
## Command Line Options
@ -263,9 +263,9 @@ to install Zsh-z.
- `-x` Remove a directory (by default, the current directory) from the database
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
## Settings
# Settings
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_`).
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_`).
* `ZSHZ_CMD` changes the command name (default: `z`)
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
@ -324,18 +324,19 @@ A good example might involve a directory tree that has Git repositories within i
(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.)
## Other Improvements and Fixes
* `z -x` works, with the help of `chpwd_functions`.
* Zsh-z is compatible with Solaris.
* Zsh-z works on Solaris.
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
* No error message is displayed when the database file has not yet been created.
* Special characters (e.g., `[`) in directory names are now supported.
* If `z -l` returns only one match, a common root is not printed.
* Exit status codes are more logical.
* Completions now work with options `-c`, `-r`, and `-t`.
* If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
* `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.
* There is no error message when the database file has not yet been created.
* There is support for special characters (e.g., `[`) in directory names.
* If `z -l` only returns one match, a common root is not printed.
* Exit status codes increasingly make sense.
* Completions work with options `-c`, `-r`, and `-t`.
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root.
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database.
## Migrating from Other Tools
@ -357,7 +358,7 @@ the line
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
## Known Bug
## Known Bugs
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
z us /usr/local/bin.

View File

@ -4,7 +4,7 @@
#
# https://github.com/agkozak/zsh-z
#
# Copyright (c) 2018-2024 Alexandros Kozak
# Copyright (c) 2018-2023 Alexandros Kozak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -120,6 +120,7 @@ fi
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
# Load zsh/system, if necessary
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null

View File

@ -13,8 +13,6 @@ function afmagic_dashes {
# the prompt, account for it when returning the number of dashes
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
echo $(( COLUMNS - ${#python_env} - 3 ))
elif [[ -n "$VIRTUAL_ENV_PROMPT" && "$PS1" = *${VIRTUAL_ENV_PROMPT}* ]]; then
echo $(( COLUMNS - ${#VIRTUAL_ENV_PROMPT} ))
else
echo $COLUMNS
fi

View File

@ -29,7 +29,7 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%} :"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$rset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[103]%}✹%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[103]%}✖%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[103]%}➜%{$reset_color%}"