From 52e848ce8f8d7370a202e0bee07ce2c32858932e Mon Sep 17 00:00:00 2001 From: Sibs <68712272+Bryan-netizen@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:07:26 +0300 Subject: [PATCH 01/77] feat(web-search): add support for Brave search engine (#11106) --- plugins/web-search/README.md | 3 ++- plugins/web-search/web-search.plugin.zsh | 34 +++++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index da90f90a0..54232a910 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -25,9 +25,10 @@ $ google oh-my-zsh Available search contexts are: | Context | URL | -|-----------------------|------------------------------------------| +| --------------------- | ---------------------------------------- | | `bing` | `https://www.bing.com/search?q=` | | `google` | `https://www.google.com/search?q=` | +| `brs` or `brave` | `https://search.brave.com/search?q=` | | `yahoo` | `https://search.yahoo.com/search?p=` | | `ddg` or `duckduckgo` | `https://www.duckduckgo.com/?q=` | | `sp` or `startpage` | `https://www.startpage.com/do/search?q=` | diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 229948894..d8b4a7f8b 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -7,22 +7,23 @@ function web_search() { typeset -A urls urls=( $ZSH_WEB_SEARCH_ENGINES - google "https://www.google.com/search?q=" - bing "https://www.bing.com/search?q=" - yahoo "https://search.yahoo.com/search?p=" - duckduckgo "https://www.duckduckgo.com/?q=" - startpage "https://www.startpage.com/do/search?q=" - yandex "https://yandex.ru/yandsearch?text=" - github "https://github.com/search?q=" - baidu "https://www.baidu.com/s?wd=" - ecosia "https://www.ecosia.org/search?q=" - goodreads "https://www.goodreads.com/search?q=" - qwant "https://www.qwant.com/?q=" - givero "https://www.givero.com/search?q=" - stackoverflow "https://stackoverflow.com/search?q=" - wolframalpha "https://www.wolframalpha.com/input/?i=" - archive "https://web.archive.org/web/*/" - scholar "https://scholar.google.com/scholar?q=" + google "https://www.google.com/search?q=" + bing "https://www.bing.com/search?q=" + brave "https://search.brave.com/search?q=" + yahoo "https://search.yahoo.com/search?p=" + duckduckgo "https://www.duckduckgo.com/?q=" + startpage "https://www.startpage.com/do/search?q=" + yandex "https://yandex.ru/yandsearch?text=" + github "https://github.com/search?q=" + baidu "https://www.baidu.com/s?wd=" + ecosia "https://www.ecosia.org/search?q=" + goodreads "https://www.goodreads.com/search?q=" + qwant "https://www.qwant.com/?q=" + givero "https://www.givero.com/search?q=" + stackoverflow "https://stackoverflow.com/search?q=" + wolframalpha "https://www.wolframalpha.com/input/?i=" + archive "https://web.archive.org/web/*/" + scholar "https://scholar.google.com/scholar?q=" ) # check whether the search engine is supported @@ -47,6 +48,7 @@ function web_search() { alias bing='web_search bing' +alias brs='web_search brave' alias google='web_search google' alias yahoo='web_search yahoo' alias ddg='web_search duckduckgo' From 08d5c936c670bd7e37902f64a065ba9f74452cb9 Mon Sep 17 00:00:00 2001 From: Syphdias Date: Fri, 14 Oct 2022 19:12:04 +0200 Subject: [PATCH 02/77] fix(git-auto-fetch): avoid password prompt with `GIT_TERMINAL_PROMPT=0` (#11234) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 2e029639c..2df34bb7b 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -28,6 +28,7 @@ function git-fetch-all { # Fetch all remotes (avoid ssh passphrase prompt) date -R &>! "$gitdir/FETCH_LOG" GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ + GIT_TERMINAL_PROMPT=0 \ command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG" ) &| } From 34cd8fbd4afce7b2beb3292f4f90ca57142f442c Mon Sep 17 00:00:00 2001 From: Warren Young Date: Mon, 29 Aug 2022 21:49:12 -0600 Subject: [PATCH 03/77] refactor(fossil): use `fossil branch current` supported since v2.7 (#11138) Using the automation-friendly "fossil branch current" feature added in Fossil 2.7 instead of ad hoc parsing of human-readable "fossil branch" output. Not only does this fix a stray space in the output, it's more robust against changes in command output in general. Closes #11138 --- plugins/fossil/fossil.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh index a2123f415..fadf6095d 100644 --- a/plugins/fossil/fossil.plugin.zsh +++ b/plugins/fossil/fossil.plugin.zsh @@ -13,12 +13,11 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖" ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔" function fossil_prompt_info() { - local info=$(fossil branch 2>&1) + local branch=$(fossil branch current 2>&1) # if we're not in a fossil repo, don't show anything - ! command grep -q "use --repo" <<< "$info" || return + ! command grep -q "use --repo" <<< "$branch" || return - local branch=$(echo $info | grep "* " | sed 's/* //g') local changes=$(fossil changes) local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN" From c7c0a8917b8ded7511c07105c82bd7417b92f7a3 Mon Sep 17 00:00:00 2001 From: tmoschou <5567550+tmoschou@users.noreply.github.com> Date: Sat, 15 Oct 2022 04:57:42 +1030 Subject: [PATCH 04/77] fix(brew): do not source `brew shellenv` if already on path (#11167) --- plugins/brew/README.md | 5 ++++- plugins/brew/brew.plugin.zsh | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 64e0e1153..9ce2c5bb0 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -10,7 +10,10 @@ plugins=(... brew) ## Shellenv -This plugin also executes `brew shellenv` at plugin load to set up many useful variables, such as `HOMEBREW_PREFIX` or `HOMEBREW_REPOSITORY`. +If `brew` is not found in the PATH, this plugin will attempt to find it in common +locations, and execute `brew shellenv` to set the environment appropriately. +This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously +defined for convenience. ## Aliases diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 4a2322216..41420b5b7 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -10,18 +10,21 @@ if (( ! $+commands[brew] )); then else return fi + + # Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is + # not already on the path, to prevent duplicate entries. This aligns with + # the behavior of the brew installer.sh post-install steps. + eval "$("$BREW_LOCATION" shellenv)" + unset BREW_LOCATION fi if [[ -z "$HOMEBREW_PREFIX" ]]; then - if [[ -z $BREW_LOCATION ]]; then - eval "$(brew shellenv)" - else - eval "$("$BREW_LOCATION" shellenv)" - fi + # Maintain compatability with potential custom user profiles, where we had + # previously relied on always sourcing shellenv. OMZ plugins should not rely + # on this to be defined due to out of order processing. + export HOMEBREW_PREFIX="$(brew --prefix)" fi -unset BREW_LOCATION - alias bcubc='brew upgrade --cask && brew cleanup' alias bcubo='brew update && brew outdated --cask' alias brewp='brew pin' From 65a1e4edbe678cdac37ad96ca4bc4f6d77e27adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 14 Oct 2022 20:31:33 +0200 Subject: [PATCH 05/77] fix(installer): detect newer Git for Windows version errors (#11157) Fixes #11157 --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index fb6973dbc..a6538f9d7 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -273,7 +273,7 @@ setup_ohmyzsh() { } ostype=$(uname) - if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -q msysgit; then + if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -Eq 'msysgit|windows'; then fmt_error "Windows/MSYS Git is not supported on Cygwin" fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 From 818f3de1fa6588a94bf207766a811992e301acf1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 1 Oct 2022 11:21:19 +0200 Subject: [PATCH 06/77] fix(debian)!: remove ar alias BREAKING CHANGE: This alias needs to be removed because is shadowing `ar` archiver. Closes #9304 --- plugins/debian/README.md | 39 ++++++++++++++++---------------- plugins/debian/debian.plugin.zsh | 7 ------ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/plugins/debian/README.md b/plugins/debian/README.md index 2ce206cfb..1db534f13 100644 --- a/plugins/debian/README.md +++ b/plugins/debian/README.md @@ -30,26 +30,25 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh ## Superuser Operations Aliases -| Alias | Command | Description | -| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | -| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files | -| `aar` | `sudo $apt_pref autoremove` | Removes packages installed automatically that are no longer needed | -| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages | -| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files | -| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages | -| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages | -| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list | -| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies | -| `afu` | `sudo apt-file update` | Update the files in packages | -| `ai` | `sudo $apt_pref install` | Command-line tool to install package | -| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line | -| `alu` | `sudo apt update && apt list -u && sudo apt upgrade` | Update, list and upgrade packages | -| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files | -| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files | -| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades | -| `di` | `sudo dpkg -i` | Install all .deb files in the current directory | -| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory | -| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use | +| Alias | Command | Description | +| -------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files | +| `aar` | `sudo $apt_pref autoremove` | Removes packages installed automatically that are no longer needed | +| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages | +| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files | +| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages | +| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages | +| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list | +| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies | +| `afu` | `sudo apt-file update` | Update the files in packages | +| `ai` | `sudo $apt_pref install` | Command-line tool to install package | +| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line | +| `alu` | `sudo apt update && apt list -u && sudo apt upgrade` | Update, list and upgrade packages | +| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files | +| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades | +| `di` | `sudo dpkg -i` | Install all .deb files in the current directory | +| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory | +| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use | ## Aliases - Commands using `su` diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index f649a5b16..2d8c4666e 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -55,7 +55,6 @@ if [[ $use_sudo -eq 1 ]]; then alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" alias ap="sudo $apt_pref purge" - alias ar="sudo $apt_pref remove" alias aar="sudo $apt_pref autoremove" # apt-get only @@ -98,11 +97,6 @@ else print "$cmd" eval "$cmd" } - function ar() { - cmd="su -lc '$apt_pref remove $@' root" - print "$cmd" - eval "$cmd" - } function aar() { cmd="su -lc '$apt_pref autoremove $@' root" print "$cmd" @@ -147,7 +141,6 @@ apt_pref_compdef au "$apt_upgr" apt_pref_compdef ai "install" apt_pref_compdef ail "install" apt_pref_compdef ap "purge" -apt_pref_compdef ar "remove" apt_pref_compdef aar "autoremove" apt_pref_compdef ads "dselect-upgrade" From 7e3231b846dec87fcf6537f6e45c9c1be9f718fe Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 18 Oct 2022 19:10:55 +0200 Subject: [PATCH 07/77] feat(z): replace `rupa/z` with `agkozak/zsh-z` (#11236) --- plugins/z/LICENSE | 21 + plugins/z/MANUAL.md | 343 +++++++++++++++ plugins/z/Makefile | 4 - plugins/z/README | 148 ------- plugins/z/README.md | 7 +- plugins/z/_z | 82 ++++ plugins/z/z.1 | 173 -------- plugins/z/z.plugin.zsh | 972 ++++++++++++++++++++++++++++++++++++++++- plugins/z/z.sh | 267 ----------- 9 files changed, 1417 insertions(+), 600 deletions(-) create mode 100644 plugins/z/LICENSE create mode 100644 plugins/z/MANUAL.md delete mode 100644 plugins/z/Makefile delete mode 100644 plugins/z/README create mode 100644 plugins/z/_z delete mode 100644 plugins/z/z.1 delete mode 100644 plugins/z/z.sh diff --git a/plugins/z/LICENSE b/plugins/z/LICENSE new file mode 100644 index 000000000..d1cca7ae5 --- /dev/null +++ b/plugins/z/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018-2022 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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md new file mode 100644 index 000000000..dcca3c452 --- /dev/null +++ b/plugins/z/MANUAL.md @@ -0,0 +1,343 @@ +# Zsh-z + +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. 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 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 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`), so you can go on using `rupa/z` when you launch `bash`. + +## Table of Contents +- [News](#news) +- [Installation](#installation) +- [Command Line Options](#command-line-options) +- [Settings](#settings) +- [Case Sensitivity](#case-sensitivity) +- [`ZSHZ_UNCOMMON`](#zshz_uncommon) +- [Making `--add` work for you](#making---add-work-for-you) +- [Other Improvements and Fixes](#other-improvements-and-fixes) +- [Migrating from Other Tools](#migrating-from-other-tools) +- [`COMPLETE_ALIASES`](#complete_aliases) +- [Known Bugs](#known-bugs) + +## News + +
+ Here are the latest features and updates. + +- June 29, 2022 + + Zsh-z is less likely to leave temporary files sitting around (props @mafredri). +- June 27, 2022 + + A bug was fixed which was preventing paths with spaces in them from being updated ([#61](https://github.com/agkozak/zsh-z/issues/61)). + + If writing to the temporary database file fails, the database will not be clobbered (props @mafredri). +- December 19, 2021 + + ZSH-z will now display tildes for `HOME` during completion when `ZSHZ_TILDE=1` has been set. +- November 11, 2021 + + A bug was fixed which was preventing ranks from being incremented. + + `--add` has been made to work with relative paths and has been documented for the user. +- October 14, 2021 + + Completions were being sorted alphabetically, rather than by rank; this error has been fixed. +- September 25, 2021 + + Orthographical change: "Zsh," not "ZSH." +- September 23, 2021 + + `z -xR` will now remove a directory *and its subdirectories* from the database. + + `z -x` and `z -xR` can now take an argument; without one, `PWD` is assumed. +- September 7, 2021 + + Fixed the unload function so that it removes the `$ZSHZ_CMD` alias (default: `z`). +- August 27, 2021 + + Using `print -v ... -f` instead of `print -v` to work around longstanding bug in Zsh involving `print -v` and multibyte strings. +- August 13, 2021 + + 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 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 formattted database entries. +- July 10, 2021 + + 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`. +- June 25, 2021 + + Setting `ZSHZ_TILDE=1` displays the `HOME` directory as `~`. +- May 7, 2021 + + Setting `ZSHZ_ECHO=1` will cause Zsh-z to display the new path when you change directories. + + Better escaping of path names to deal paths containing the characters ``\`()[]``. +- February 15, 2021 + + 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. +- January 31, 2021 + + 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. + + `_zshz_precmd` simply returns if `PWD` is `HOME` or in `ZSH_EXCLUDE_DIRS`, rather than waiting for `zshz` to do that. +- January 17, 2021 + + Made sure that the `PUSHD_IGNORE_DUPS` option is respected. +- January 14, 2021 + + The `z -h` help text now breaks at spaces. + + `z -l` was not working for Zsh version < 5. +- January 11, 2021 + + Major refactoring of the code. + + `z -lr` and `z -lt` work as expected. + + `EXTENDED_GLOB` has been disabled within the plugin to accomodate old-fashioned Windows directories with names such as `Progra~1`. + + Removed `zshelldoc` documentation. +- January 6, 2021 + + I have corrected the frecency routine so that it matches `rupa/z`'s math, but for the present, Zsh-z will continue to display ranks as 1/10000th of what they are in `rupa/z` -- [they had to multiply theirs by 10000](https://github.com/rupa/z/commit/f1f113d9bae9effaef6b1e15853b5eeb445e0712) to work around `bash`'s inadequacies at dealing with decimal fractions. +- January 5, 2021 + + If you try `z foo`, and `foo` is not in the database but `${PWD}/foo` is a valid directory, Zsh-z will `cd` to it. +- 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 datafiles were having their symlinks overwritten; this bug has been fixed. + +
+ +## Installation + +### General observations + +This script can be installed simply by downloading it and sourcing it from your `.zshrc`: + + source /path/to/zsh-z.plugin.zsh + +For tab completion to work, you will want to have loaded `compinit`. The frameworks handle this themselves. If you are not using a framework, put + + autoload -U compinit && compinit + +in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`. + +If you add + + zstyle ':completion:*' menu select + +to your `.zshrc`, your completion menus will look very nice. This `zstyle` invocation should work with any of the frameworks below as well. + +### For [antigen](https://github.com/zsh-users/antigen) users + +Add the line + + antigen bundle agkozak/zsh-z + +to your `.zshrc`, somewhere above the line that says `antigen apply`. + +### For [oh-my-zsh](http://ohmyz.sh/) users + +Execute the following command: + + git clone https://github.com/agkozak/zsh-z ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z + +and add `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`. + +### For [prezto](https://github.com/sorin-ionescu/prezto) users + +Execute the following command: + + git clone https://github.com/agkozak/zsh-z.git ~/.zprezto-contrib/zsh-z + +Then edit your `~/.zpreztorc` file. Make sure the line that says + + zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib + +is uncommented. Then find the section that specifies which modules are to be loaded; it should look something like this: + + zstyle ':prezto:load' pmodule \ + 'environment' \ + 'terminal' \ + 'editor' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'prompt' + +Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g., + + zstyle ':prezto:load' pmodule \ + 'environment' \ + 'terminal' \ + 'editor' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'prompt' \ + 'zsh-z' + +Then relaunch `zsh`. + +### For [zcomet](https://github.com/agkozak/zcomet) users + +Simply add + + zcomet load agkozak/zsh-z + +to your `.zshrc` (below where you source `zcomet.zsh` and above where you run `zcomet compinit`). + +### For [zgen](https://github.com/tarjoilija/zgen) users + +Add the line + + zgen load agkozak/zsh-z + +somewhere above the line that says `zgen save`. Then run + + zgen reset + zsh + +to refresh your init script. + +### For [Zim](https://github.com/zimfw/zimfw) + +Add the following line to your `.zimrc`: + + zmodule https://github.com/agkozak/zsh-z + +Then run + + zimfw install + +and restart your shell. + +### For [Zinit](https://github.com/zdharma-continuum/zinit) users + +Add the line + + zinit load agkozak/zsh-z + +to your `.zshrc`. + +`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 + +Add the line + + znap source agkozak/zsh-z + +somewhere below the line where you `source` Znap itself. + +### For [zplug](https://github.com/zplug/zplug) users + +Add the line + + zplug "agkozak/zsh-z" + +somewhere above the line that says `zplug load`. Then run + + zplug install + zplug load + +to install `zsh-z`. + +## Command Line Options + +- `--add` Add a directory to the database +- `-c` Only match subdirectories of the current directory +- `-e` Echo the best match without going to it +- `-h` Display help +- `-l` List all matches without going to them +- `-r` Match by rank (i.e. how much time you spend in directories) +- `-t` Time -- match by how recently you have been to directories +- `-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 + +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_COMPLETION` can be `'frecent'` (default) or `'legacy'`, depending on whether you want your completion results sorted according to frecency or simply sorted alphabetically +* `ZSHZ_DATA` changes the database file (default: `~/.z`) +* `ZSHZ_ECHO` displays the new path name when changing directories (default: `0`) +* `ZSHZ_EXCLUDE_DIRS` is an array of directories to keep out of the database (default: empty) +* `ZSHZ_KEEP_DIRS` is an array of directories that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted) (default: empty) +* `ZSHZ_MAX_SCORE` is the maximum combined score the database entries can have before they begin to age and potentially drop out of the database (default: 9000) +* `ZSHZ_NO_RESOLVE_SYMLINKS` prevents symlink resolution (default: `0`) +* `ZSHZ_OWNER` allows usage when in `sudo -s` mode (default: empty) +* `ZSHZ_TILDE` displays the name of the `HOME` directory as a `~` (default: `0`) +* `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`) +* `ZSHZ_UNCOMMON` changes the logic used to calculate the directory jumped to; [see below](#zshz_uncommon`) (default: `0`) + +## Case sensitivity + +The default behavior of Zsh-z is to try to find a case-sensitive match. If there is none, then Zsh-z tries to find a case-insensitive match. + +Some users prefer simple case-insensitivity; this behavior can be enabled by setting + + ZSHZ_CASE=ignore + +If you like Vim's `smartcase` setting, where lowercase patterns are case-insensitive while patterns with any uppercase characters are treated case-sensitively, try setting + + ZSHZ_CASE=smart + +## `ZSHZ_UNCOMMON` + +A common complaint about the default behavior of `rupa/z` and Zsh-z involves "common prefixes." If you type `z code` and the best matches, in increasing order, are + + /home/me/code/foo + /home/me/code/bar + /home/me/code/bat + +Zsh-z will see that all possible matches share a common prefix and will send you to that directory -- `/home/me/code` -- which is often a desirable result. But if the possible matches are + + /home/me/.vscode/foo + /home/me/code/foo + /home/me/code/bar + /home/me/code/bat + +then there is no common prefix. In this case, `z code` will simply send you to the highest-ranking match, `/home/me/code/bat`. + +You may enable an alternate, experimental behavior by setting `ZSHZ_UNCOMMON=1`. If you do that, Zsh-z will not jump to a common prefix, even if one exists. Instead, it chooses the highest-ranking match -- but it drops any subdirectories that do not include the search term. So if you type `z bat` and `/home/me/code/bat` is the best match, that is exactly where you will end up. If, however, you had typed `z code` and the best match was also `/home/me/code/bat`, you would have ended up in `/home/me/code` (because `code` was what you had searched for). This feature is still in development, and feedback is welcome. + +## Making `--add` Work for You + +Zsh-z internally uses the `--add` option to add paths to its database. @zachriggle pointed out to me that users might want to use `--add` themselves, so I have altered it a little to make it more user-friendly. + +A good example might involve a directory tree that has Git repositories within it. The working directories could be added to the Zsh-z database as a batch with + + for i in $(find $PWD -maxdepth 3 -name .git -type d); do + z --add ${i:h} + done + +(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 works on Solaris. +* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one. +* 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 + +Zsh-z's database format is identical to that of `rupa/z`. You may switch freely between the two tools (I still use `rupa/z` for `bash`). `fasd` also uses that database format, but it stores it by default in `~/.fasd`, so you will have to `cp ~/.fasd ~/.z` if you want to use your old directory history. + +If you are coming to Zsh-z (or even to the original `rupa/z`, for that matter) from `autojump`, try using my [`jumpstart-z`](https://github.com/agkozak/jumpstart-z/blob/master/jumpstart-z) tool to convert your old database to the Zsh-z format, or simply run + + awk -F "\t" '{printf("%s|%0.f|%s\n", $2, $1, '"$(date +%s)"')}' < /path/to/autojump.txt > ~/.z + +## `COMPLETE_ALIASES` + +`z`, or any alternative you set up using `$ZSH_CMD` or `$_Z_CMD`, is an alias. `setopt COMPLETE_ALIASES` divorces the tab completion for aliases from the underlying commands they invoke, so if you enable `COMPLETE_ALIASES`, tab completion for Zsh-z will be broken. You can get it working again, however, by adding under + + setopt COMPLETE_ALIASES + +the line + + compdef _zshz ${ZSHZ_CMD:-${_Z_CMD:-z}} + +That will re-bind `z` or the command of your choice to the underlying Zsh-z function. + +## Known Bugs +It is possible to run a completion on a string with spaces in it, e.g., `z us bi` 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. + +You get where you want to go, but the detritus on the command line is annoying. This is also a problem in `rupa/z`, but I am keen on eventually eliminating this glitch. Advice is welcome. diff --git a/plugins/z/Makefile b/plugins/z/Makefile deleted file mode 100644 index dcf433d40..000000000 --- a/plugins/z/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -readme: - @groff -man -Tascii z.1 | col -bx - -.PHONY: readme diff --git a/plugins/z/README b/plugins/z/README deleted file mode 100644 index 47e54c57a..000000000 --- a/plugins/z/README +++ /dev/null @@ -1,148 +0,0 @@ -Z(1) User Commands Z(1) - - - -NAME - z - jump around - -SYNOPSIS - z [-chlrtx] [regex1 regex2 ... regexn] - -AVAILABILITY - bash, zsh - -DESCRIPTION - Tracks your most used directories, based on 'frecency'. - - After a short learning phase, z will take you to the most 'frecent' - directory that matches ALL of the regexes given on the command line, in - order. - - For example, z foo bar would match /foo/bar but not /bar/foo. - -OPTIONS - -c restrict matches to subdirectories of the current directory - - -e echo the best match, don't cd - - -h show a brief help message - - -l list only - - -r match by rank only - - -t match by recent access only - - -x remove the current directory from the datafile - -EXAMPLES - z foo cd to most frecent dir matching foo - - z foo bar cd to most frecent dir matching foo, then bar - - z -r foo cd to highest ranked dir matching foo - - z -t foo cd to most recently accessed dir matching foo - - z -l foo list all dirs matching foo (by frecency) - -NOTES - Installation: - Put something like this in your $HOME/.bashrc or $HOME/.zshrc: - - . /path/to/z.sh - - cd around for a while to build up the db. - - PROFIT!! - - Optionally: - Set $_Z_CMD to change the command name (default z). - Set $_Z_DATA to change the datafile (default $HOME/.z). - Set $_Z_MAX_SCORE lower to age entries out faster (default - 9000). - Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution. - Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your- - self. - Set $_Z_EXCLUDE_DIRS to an array of directory trees to exclude. - Set $_Z_OWNER to allow usage when in 'sudo -s' mode. - (These settings should go in .bashrc/.zshrc before the line - added above.) - Install the provided man page z.1 somewhere in your MANPATH, - like /usr/local/man/man1. - - Aging: - The rank of directories maintained by z undergoes aging based on a sim- - ple formula. The rank of each entry is incremented every time it is - accessed. When the sum of ranks is over 9000, all ranks are multiplied - by 0.99. Entries with a rank lower than 1 are forgotten. - - Frecency: - Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted - rank that depends on how often and how recently something occurred. As - far as I know, Mozilla came up with the term. - - To z, a directory that has low ranking but has been accessed recently - will quickly have higher rank than a directory accessed frequently a - long time ago. - - Frecency is determined at runtime. - - Common: - When multiple directories match all queries, and they all have a common - prefix, z will cd to the shortest matching directory, without regard to - priority. This has been in effect, if undocumented, for quite some - time, but should probably be configurable or reconsidered. - - Tab Completion: - z supports tab completion. After any number of arguments, press TAB to - complete on directories that match each argument. Due to limitations of - the completion implementations, only the last argument will be com- - pleted in the shell. - - Internally, z decides you've requested a completion if the last argu- - ment passed is an absolute path to an existing directory. This may - cause unexpected behavior if the last argument to z begins with /. - -ENVIRONMENT - A function _z() is defined. - - The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set, - $_Z_CMD defaults to z. - - The environment variable $_Z_DATA can be used to control the datafile - location. If it is not defined, the location defaults to $HOME/.z. - - The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent - resolving of symlinks. If it is not set, symbolic links will be - resolved when added to the datafile. - - In bash, z appends a command to the PROMPT_COMMAND environment variable - to maintain its database. In zsh, z appends a function _z_precmd to the - precmd_functions array. - - The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want - to handle PROMPT_COMMAND or precmd yourself. - - The environment variable $_Z_EXCLUDE_DIRS can be set to an array of - directory trees to exclude from tracking. $HOME is always excluded. - Directories must be full paths without trailing slashes. - - The environment variable $_Z_OWNER can be set to your username, to - allow usage of z when your sudo environment keeps $HOME set. - -FILES - Data is stored in $HOME/.z. This can be overridden by setting the - $_Z_DATA environment variable. When initialized, z will raise an error - if this path is a directory, and not function correctly. - - A man page (z.1) is provided. - -SEE ALSO - regex(7), pushd, popd, autojump, cdargs - - Please file bugs at https://github.com/rupa/z/ - - - -z January 2013 Z(1) diff --git a/plugins/z/README.md b/plugins/z/README.md index ea8d4610a..5b7d6f649 100644 --- a/plugins/z/README.md +++ b/plugins/z/README.md @@ -1,8 +1,9 @@ # z - jump around -This plugin defines the [z command](https://github.com/rupa/z) that tracks your most visited directories and allows you to access them with very few keystrokes. +This plugin defines the [z command](https://github.com/agkozak/zsh-z) that tracks your most visited directories and allows you to access them with very few keystrokes. ### Example + Assume that you have previously visited directory `~/.oh-my-zsh/plugins`. From any folder in your command line, you can quickly access it by using a regex match to this folder: ```bash @@ -11,6 +12,7 @@ Assume that you have previously visited directory `~/.oh-my-zsh/plugins`. From a ``` ### Setup + To enable z, add `z` to your `plugins` array in your zshrc file: ```zsh @@ -19,5 +21,4 @@ plugins=(... z) ### Further reading -For advanced usage and details of z, see [README](./README) (in man page format, copied from [rupa/z](https://github.com/rupa/z)). - +For advanced usage and details of z, see [MANUAL](./MANUAL.md) (copied from [agkozak/zsh-z](https://github.com/agkozak/zsh-z)). diff --git a/plugins/z/_z b/plugins/z/_z new file mode 100644 index 000000000..9891a52ed --- /dev/null +++ b/plugins/z/_z @@ -0,0 +1,82 @@ +#compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}} +# +# Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort, +# date, or sed +# +# https://github.com/agkozak/zsh-z +# +# Copyright (c) 2018-2022 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and +# licensed under the WTFPL license, Version 2.a +# +# shellcheck shell=ksh + +############################################################ +# Zsh-z COMPLETIONS +############################################################ +emulate -L zsh +(( ZSHZ_DEBUG )) && + setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null + +# TODO: This routine currently reproduces z's feature of allowing spaces to be +# used as wildcards in completions, so that +# +# z us lo bi +# +# can expand to +# +# z /usr/local/bin +# +# but it also reproduces z's buggy display on the commandline, viz. +# +# z us lo /usr/local/bin +# +# Address. + +local completions expl completion +local -a completion_list + +completions=$(zshz --complete ${(@)words:1}) +[[ -z $completions ]] && return 1 + +for completion in ${(f)completions[@]}; do + if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then + completion="~${(q)${completion#${HOME}}}" + else + completion="${(q)completion}" + fi + completion_list+=( $completion ) +done + +_description -V completion_list expl 'directories' + +if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then + compadd "${expl[@]}" -QU -- "${completion_list[@]}" +else + compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}" +fi + +compstate[insert]=menu + +return 0 + +# vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2: diff --git a/plugins/z/z.1 b/plugins/z/z.1 deleted file mode 100644 index 182f98176..000000000 --- a/plugins/z/z.1 +++ /dev/null @@ -1,173 +0,0 @@ -.TH "Z" "1" "January 2013" "z" "User Commands" -.SH -NAME -z \- jump around -.SH -SYNOPSIS -z [\-chlrtx] [regex1 regex2 ... regexn] -.SH -AVAILABILITY -bash, zsh -.SH -DESCRIPTION -Tracks your most used directories, based on 'frecency'. -.P -After a short learning phase, \fBz\fR will take you to the most 'frecent' -directory that matches ALL of the regexes given on the command line, in order. - -For example, \fBz foo bar\fR would match \fB/foo/bar\fR but not \fB/bar/foo\fR. -.SH -OPTIONS -.TP -\fB\-c\fR -restrict matches to subdirectories of the current directory -.TP -\fB\-e\fR -echo the best match, don't cd -.TP -\fB\-h\fR -show a brief help message -.TP -\fB\-l\fR -list only -.TP -\fB\-r\fR -match by rank only -.TP -\fB\-t\fR -match by recent access only -.TP -\fB\-x\fR -remove the current directory from the datafile -.SH EXAMPLES -.TP 14 -\fBz foo\fR -cd to most frecent dir matching foo -.TP 14 -\fBz foo bar\fR -cd to most frecent dir matching foo, then bar -.TP 14 -\fBz -r foo\fR -cd to highest ranked dir matching foo -.TP 14 -\fBz -t foo\fR -cd to most recently accessed dir matching foo -.TP 14 -\fBz -l foo\fR -list all dirs matching foo (by frecency) -.SH -NOTES -.SS -Installation: -.P -Put something like this in your \fB$HOME/.bashrc\fR or \fB$HOME/.zshrc\fR: -.RS -.P -\fB. /path/to/z.sh\fR -.RE -.P -\fBcd\fR around for a while to build up the db. -.P -PROFIT!! -.P -Optionally: -.RS -Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR). -.RE -.RS -Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR). -.RE -.RS -Set \fB$_Z_MAX_SCORE\fR lower to age entries out faster (default \fB9000\fR). -.RE -.RS -Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution. -.RE -.RS -Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself. -.RE -.RS -Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directory trees to exclude. -.RE -.RS -Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode. -.RE -.RS -(These settings should go in .bashrc/.zshrc before the line added above.) -.RE -.RS -Install the provided man page \fBz.1\fR somewhere in your \f$MANPATH, like -\fB/usr/local/man/man1\fR. -.RE -.SS -Aging: -The rank of directories maintained by \fBz\fR undergoes aging based on a simple -formula. The rank of each entry is incremented every time it is accessed. When -the sum of ranks is over 9000, all ranks are multiplied by 0.99. Entries with a -rank lower than 1 are forgotten. -.SS -Frecency: -Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank -that depends on how often and how recently something occurred. As far as I -know, Mozilla came up with the term. -.P -To \fBz\fR, a directory that has low ranking but has been accessed recently -will quickly have higher rank than a directory accessed frequently a long time -ago. -.P -Frecency is determined at runtime. -.SS -Common: -When multiple directories match all queries, and they all have a common prefix, -\fBz\fR will cd to the shortest matching directory, without regard to priority. -This has been in effect, if undocumented, for quite some time, but should -probably be configurable or reconsidered. -.SS -Tab Completion: -\fBz\fR supports tab completion. After any number of arguments, press TAB to -complete on directories that match each argument. Due to limitations of the -completion implementations, only the last argument will be completed in the -shell. -.P -Internally, \fBz\fR decides you've requested a completion if the last argument -passed is an absolute path to an existing directory. This may cause unexpected -behavior if the last argument to \fBz\fR begins with \fB/\fR. -.SH -ENVIRONMENT -A function \fB_z()\fR is defined. -.P -The contents of the variable \fB$_Z_CMD\fR is aliased to \fB_z 2>&1\fR. If not -set, \fB$_Z_CMD\fR defaults to \fBz\fR. -.P -The environment variable \fB$_Z_DATA\fR can be used to control the datafile -location. If it is not defined, the location defaults to \fB$HOME/.z\fR. -.P -The environment variable \fB$_Z_NO_RESOLVE_SYMLINKS\fR can be set to prevent -resolving of symlinks. If it is not set, symbolic links will be resolved when -added to the datafile. -.P -In bash, \fBz\fR appends a command to the \fBPROMPT_COMMAND\fR environment -variable to maintain its database. In zsh, \fBz\fR appends a function -\fB_z_precmd\fR to the \fBprecmd_functions\fR array. -.P -The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to -handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself. -.P -The environment variable \fB$_Z_EXCLUDE_DIRS\fR can be set to an array of -directory trees to exclude from tracking. \fB$HOME\fR is always excluded. -Directories must be full paths without trailing slashes. -.P -The environment variable \fB$_Z_OWNER\fR can be set to your username, to -allow usage of \fBz\fR when your sudo environment keeps \fB$HOME\fR set. -.SH -FILES -Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the -\fB$_Z_DATA\fR environment variable. When initialized, \fBz\fR will raise an -error if this path is a directory, and not function correctly. -.P -A man page (\fBz.1\fR) is provided. -.SH -SEE ALSO -regex(7), pushd, popd, autojump, cdargs -.P -Please file bugs at https://github.com/rupa/z/ diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh index 7d3eacac0..209edfea7 100644 --- a/plugins/z/z.plugin.zsh +++ b/plugins/z/z.plugin.zsh @@ -1,6 +1,968 @@ -# Handle $0 according to the standard: -# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html -0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" -0="${${(M)0:#/*}:-$PWD/$0}" +################################################################################ +# Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort, +# date, or sed +# +# https://github.com/agkozak/zsh-z +# +# Copyright (c) 2018-2022 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and +# licensed under the WTFPL license, Version 2. +# +# Zsh-z maintains a jump-list of the directories you actually use. +# +# INSTALL: +# * put something like this in your .zshrc: +# source /path/to/zsh-z.plugin.zsh +# * cd around for a while to build up the database +# +# USAGE: +# * z foo cd to the most frecent directory matching foo +# * z foo bar cd to the most frecent directory matching both foo and bar +# (e.g. /foo/bat/bar/quux) +# * z -r foo cd to the highest ranked directory matching foo +# * z -t foo cd to most recently accessed directory matching foo +# * z -l foo List matches instead of changing directories +# * z -e foo Echo the best match without changing directories +# * z -c foo Restrict matches to subdirectories of PWD +# * z -x Remove a directory (default: PWD) from the database +# * z -xR Remove a directory (default: PWD) and its subdirectories from +# the database +# +# ENVIRONMENT VARIABLES: +# +# ZSHZ_CASE -> if `ignore', pattern matching is case-insensitive; if `smart', +# pattern matching is case-insensitive only when the pattern is all +# lowercase +# ZSHZ_CMD -> name of command (default: z) +# ZSHZ_COMPLETION -> completion method (default: 'frecent'; 'legacy' for +# alphabetic sorting) +# ZSHZ_DATA -> name of datafile (default: ~/.z) +# ZSHZ_EXCLUDE_DIRS -> array of directories to exclude from your database +# (default: empty) +# ZSHZ_KEEP_DIRS -> array of directories that should not be removed from the +# database, even if they are not currently available (default: empty) +# ZSHZ_MAX_SCORE -> maximum combined score the database entries can have +# before beginning to age (default: 9000) +# ZSHZ_NO_RESOLVE_SYMLINKS -> '1' prevents symlink resolution +# ZSHZ_OWNER -> your username (if you want use Zsh-z while using sudo -s) +# ZSHZ_UNCOMMON -> if 1, do not jump to "common directories," but rather drop +# subdirectories based on what the search string was (default: 0) +################################################################################ -source "${0:h}/z.sh" +autoload -U is-at-least + +if ! is-at-least 4.3.11; then + print "Zsh-z requires Zsh v4.3.11 or higher." >&2 && exit +fi + +############################################################ +# The help message +# +# Globals: +# ZSHZ_CMD +############################################################ +_zshz_usage() { + print "Usage: ${ZSHZ_CMD:-${_Z_CMD:-z}} [OPTION]... [ARGUMENT] +Jump to a directory that you have visited frequently or recently, or a bit of both, based on the partial string ARGUMENT. + +With no ARGUMENT, list the directory history in ascending rank. + + --add Add a directory to the database + -c Only match subdirectories of the current directory + -e Echo the best match without going to it + -h Display this help and exit + -l List all matches without going to them + -r Match by rank + -t Match by recent access + -x Remove a directory from the database (by default, the current directory) + -xR Remove a directory and its subdirectories from the database (by default, the current directory)" | + fold -s -w $COLUMNS >&2 +} + +# Load zsh/datetime module, if necessary +(( $+EPOCHSECONDS )) || zmodload zsh/datetime + +# Load zsh/files, if necessary +[[ ${builtins[zf_chown]} == 'defined' && + ${builtins[zf_mv]} == 'defined' && + ${builtins[zf_rm]} == 'defined' ]] || + zmodload -F zsh/files b:zf_chown b:zf_mv b:zf_rm + +# Load zsh/system, if necessary +[[ ${modules[zsh/system]} == 'loaded' ]] || zmodload zsh/system &> /dev/null + +# Global associative array for internal use +typeset -gA ZSHZ + +# Make sure ZSHZ_EXCLUDE_DIRS has been declared so that other scripts can +# simply append to it +(( ${+ZSHZ_EXCLUDE_DIRS} )) || typeset -gUa ZSHZ_EXCLUDE_DIRS + +# Determine if zsystem flock is available +zsystem supports flock &> /dev/null && ZSHZ[USE_FLOCK]=1 + +# Determine if `print -v' is supported +is-at-least 5.3.0 && ZSHZ[PRINTV]=1 + +############################################################ +# The Zsh-z Command +# +# Globals: +# ZSHZ +# ZSHZ_CASE +# ZSHZ_COMPLETION +# ZSHZ_DATA +# ZSHZ_DEBUG +# ZSHZ_EXCLUDE_DIRS +# ZSHZ_KEEP_DIRS +# ZSHZ_MAX_SCORE +# ZSHZ_OWNER +# +# Arguments: +# $* Command options and arguments +############################################################ +zshz() { + + # Don't use `emulate -L zsh' - it breaks PUSHD_IGNORE_DUPS + setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT EXTENDED_GLOB + (( ZSHZ_DEBUG )) && setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL + + local REPLY + local -a lines + + # Allow the user to specify the datafile name in $ZSHZ_DATA (default: ~/.z) + # If the datafile is a symlink, it gets dereferenced + local datafile=${${ZSHZ_DATA:-${_Z_DATA:-${HOME}/.z}}:A} + + # If the datafile is a directory, print a warning and exit + if [[ -d $datafile ]]; then + print "ERROR: Zsh-z's datafile (${datafile}) is a directory." >&2 + exit + fi + + # Make sure that the datafile exists before attempting to read it or lock it + # for writing + [[ -f $datafile ]] || touch "$datafile" + + # Bail if we don't own the datafile and $ZSHZ_OWNER is not set + [[ -z ${ZSHZ_OWNER:-${_Z_OWNER}} && -f $datafile && ! -O $datafile ]] && + return + + # Load the datafile into an array and parse it + lines=( ${(f)"$(< $datafile)"} ) + # Discard entries that are incomplete or incorrectly formatted + lines=( ${(M)lines:#/*\|[[:digit:]]##[.,]#[[:digit:]]#\|[[:digit:]]##} ) + + ############################################################ + # Add a path to or remove one from the datafile + # + # Globals: + # ZSHZ + # ZSHZ_EXCLUDE_DIRS + # ZSHZ_OWNER + # + # Arguments: + # $1 Which action to perform (--add/--remove) + # $2 The path to add + ############################################################ + _zshz_add_or_remove_path() { + local action=${1} + shift + + if [[ $action == '--add' ]]; then + + # TODO: The following tasks are now handled by _agkozak_precmd. Dead code? + + # Don't add $HOME + [[ $* == $HOME ]] && return + + # Don't track directory trees excluded in ZSHZ_EXCLUDE_DIRS + local exclude + for exclude in ${(@)ZSHZ_EXCLUDE_DIRS:-${(@)_Z_EXCLUDE_DIRS}}; do + case $* in + ${exclude}|${exclude}/*) return ;; + esac + done + fi + + # A temporary file that gets copied over the datafile if all goes well + local tempfile="${datafile}.${RANDOM}" + + # See https://github.com/rupa/z/pull/199/commits/ed6eeed9b70d27c1582e3dd050e72ebfe246341c + if (( ZSHZ[USE_FLOCK] )); then + + local lockfd + + # Grab exclusive lock (released when function exits) + zsystem flock -f lockfd "$datafile" 2> /dev/null || return + + fi + + integer tmpfd + case $action in + --add) + exec {tmpfd}>|"$tempfile" # Open up tempfile for writing + _zshz_update_datafile $tmpfd "$*" + local ret=$? + ;; + --remove) + local xdir # Directory to be removed + + if (( ${ZSHZ_NO_RESOLVE_SYMLINKS:-${_Z_NO_RESOLVE_SYMLINKS}} )); then + [[ -d ${${*:-${PWD}}:a} ]] && xdir=${${*:-${PWD}}:a} + else + [[ -d ${${*:-${PWD}}:A} ]] && xdir=${${*:-${PWD}}:a} + fi + + local -a lines_to_keep + if (( ${+opts[-R]} )); then + # Prompt user before deleting entire database + if [[ $xdir == '/' ]] && ! read -q "?Delete entire Zsh-z database? "; then + print && return 1 + fi + # All of the lines that don't match the directory to be deleted + lines_to_keep=( ${lines:#${xdir}\|*} ) + # Or its subdirectories + lines_to_keep=( ${lines_to_keep:#${xdir%/}/**} ) + else + # All of the lines that don't match the directory to be deleted + lines_to_keep=( ${lines:#${xdir}\|*} ) + fi + if [[ $lines != "$lines_to_keep" ]]; then + lines=( $lines_to_keep ) + else + return 1 # The $PWD isn't in the datafile + fi + exec {tmpfd}>|"$tempfile" # Open up tempfile for writing + print -u $tmpfd -l -- $lines + local ret=$? + ;; + esac + + if (( tmpfd != 0 )); then + # Close tempfile + exec {tmpfd}>&- + fi + + if (( ret != 0 )); then + # Avoid clobbering the datafile if the write to tempfile failed + zf_rm -f "$tempfile" + return $ret + fi + + local owner + owner=${ZSHZ_OWNER:-${_Z_OWNER}} + + if (( ZSHZ[USE_FLOCK] )); then + zf_mv "$tempfile" "$datafile" 2> /dev/null || zf_rm -f "$tempfile" + + if [[ -n $owner ]]; then + zf_chown ${owner}:"$(id -ng ${owner})" "$datafile" + fi + else + if [[ -n $owner ]]; then + zf_chown "${owner}":"$(id -ng "${owner}")" "$tempfile" + fi + zf_mv -f "$tempfile" "$datafile" 2> /dev/null || zf_rm -f "$tempfile" + fi + + # In order to make z -x work, we have to disable zsh-z's adding + # to the database until the user changes directory and the + # chpwd_functions are run + if [[ $action == '--remove' ]]; then + ZSHZ[DIRECTORY_REMOVED]=1 + fi + } + + ############################################################ + # Read the curent datafile contents, update them, "age" them + # when the total rank gets high enough, and print the new + # contents to STDOUT. + # + # Globals: + # ZSHZ_KEEP_DIRS + # ZSHZ_MAX_SCORE + # + # Arguments: + # $1 File descriptor linked to tempfile + # $2 Path to be added to datafile + ############################################################ + _zshz_update_datafile() { + + integer fd=$1 + local -A rank time + + # Characters special to the shell (such as '[]') are quoted with backslashes + # See https://github.com/rupa/z/issues/246 + local add_path=${(q)2} + + local -a existing_paths + local now=$EPOCHSECONDS line dir + local path_field rank_field time_field count x + + rank[$add_path]=1 + time[$add_path]=$now + + # Remove paths from database if they no longer exist + for line in $lines; do + if [[ ! -d ${line%%\|*} ]]; then + for dir in ${(@)ZSHZ_KEEP_DIRS}; do + if [[ ${line%%\|*} == ${dir}/* || + ${line%%\|*} == $dir || + $dir == '/' ]]; then + existing_paths+=( $line ) + fi + done + else + existing_paths+=( $line ) + fi + done + lines=( $existing_paths ) + + for line in $lines; do + path_field=${(q)line%%\|*} + rank_field=${${line%\|*}#*\|} + time_field=${line##*\|} + + # When a rank drops below 1, drop the path from the database + (( rank_field < 1 )) && continue + + if [[ $path_field == $add_path ]]; then + rank[$path_field]=$rank_field + (( rank[$path_field]++ )) + time[$path_field]=$now + else + rank[$path_field]=$rank_field + time[$path_field]=$time_field + fi + (( count += rank_field )) + done + if (( count > ${ZSHZ_MAX_SCORE:-${_Z_MAX_SCORE:-9000}} )); then + # Aging + for x in ${(k)rank}; do + print -u $fd -- "$x|$(( 0.99 * rank[$x] ))|${time[$x]}" || return 1 + done + else + for x in ${(k)rank}; do + print -u $fd -- "$x|${rank[$x]}|${time[$x]}" || return 1 + done + fi + } + + ############################################################ + # The original tab completion method + # + # String processing is smartcase -- case-insensitive if the + # search string is lowercase, case-sensitive if there are + # any uppercase letters. Spaces in the search string are + # treated as *'s in globbing. Read the contents of the + # datafile and print matches to STDOUT. + # + # Arguments: + # $1 The string to be completed + ############################################################ + _zshz_legacy_complete() { + + local line path_field path_field_normalized + + # Replace spaces in the search string with asterisks for globbing + 1=${1//[[:space:]]/*} + + for line in $lines; do + + path_field=${line%%\|*} + + path_field_normalized=$path_field + if (( ZSHZ_TRAILING_SLASH )); then + path_field_normalized=${path_field%/}/ + fi + + # If the search string is all lowercase, the search will be case-insensitive + if [[ $1 == "${1:l}" && ${path_field_normalized:l} == *${~1}* ]]; then + print -- $path_field + # Otherwise, case-sensitive + elif [[ $path_field_normalized == *${~1}* ]]; then + print -- $path_field + fi + + done + # TODO: Search strings with spaces in them are currently treated case- + # insensitively. + } + + ############################################################ + # `print' or `printf' to REPLY + # + # Variable assignment through command substitution, of the + # form + # + # foo=$( bar ) + # + # requires forking a subshell; on Cygwin/MSYS2/WSL1 that can + # be surprisingly slow. Zsh-z avoids doing that by printing + # values to the variable REPLY. Since Zsh v5.3.0 that has + # been possible with `print -v'; for earlier versions of the + # shell, the values are placed on the editing buffer stack + # and then `read' into REPLY. + # + # Globals: + # ZSHZ + # + # Arguments: + # Options and parameters for `print' + ############################################################ + _zshz_printv() { + # NOTE: For a long time, ZSH's `print -v' had a tendency + # to mangle multibyte strings: + # + # https://www.zsh.org/mla/workers/2020/msg00307.html + # + # The bug was fixed in late 2020: + # + # https://github.com/zsh-users/zsh/commit/b6ba74cd4eaec2b6cb515748cf1b74a19133d4a4#diff-32bbef18e126b837c87b06f11bfc61fafdaa0ed99fcb009ec53f4767e246b129 + # + # In order to support shells with the bug, we must use a form of `printf`, + # which does not exhibit the undesired behavior. See + # + # https://www.zsh.org/mla/workers/2020/msg00308.html + + if (( ZSHZ[PRINTV] )); then + builtin print -v REPLY -f %s $@ + else + builtin print -z $@ + builtin read -rz REPLY + fi + } + + ############################################################ + # If matches share a common root, find it, and put it in + # REPLY for _zshz_output to use. + # + # Arguments: + # $1 Name of associative array of matches and ranks + ############################################################ + _zshz_find_common_root() { + local -a common_matches + local x short + + common_matches=( ${(@Pk)1} ) + + for x in ${(@)common_matches}; do + if [[ -z $short ]] || (( $#x < $#short )) || [[ $x != ${short}/* ]]; then + short=$x + fi + done + + [[ $short == '/' ]] && return + + for x in ${(@)common_matches}; do + [[ $x != $short* ]] && return + done + + _zshz_printv -- $short + } + + ############################################################ + # Calculate a common root, if there is one. Then do one of + # the following: + # + # 1) Print a list of completions in frecent order; + # 2) List them (z -l) to STDOUT; or + # 3) Put a common root or best match into REPLY + # + # Globals: + # ZSHZ_UNCOMMON + # + # Arguments: + # $1 Name of an associative array of matches and ranks + # $2 The best match or best case-insensitive match + # $3 Whether to produce a completion, a list, or a root or + # match + ############################################################ + _zshz_output() { + + local match_array=$1 match=$2 format=$3 + local common k x + local -a descending_list output + local -A output_matches + + output_matches=( ${(Pkv)match_array} ) + + _zshz_find_common_root $match_array + common=$REPLY + + case $format in + + completion) + for k in ${(@k)output_matches}; do + _zshz_printv -f "%.2f|%s" ${output_matches[$k]} $k + descending_list+=( ${(f)REPLY} ) + REPLY='' + done + descending_list=( ${${(@On)descending_list}#*\|} ) + print -l $descending_list + ;; + + list) + local path_to_display + for x in ${(k)output_matches}; do + if (( ${output_matches[$x]} )); then + path_to_display=$x + (( ZSHZ_TILDE )) && + path_to_display=${path_to_display/#${HOME}/\~} + _zshz_printv -f "%-10d %s\n" ${output_matches[$x]} $path_to_display + output+=( ${(f)REPLY} ) + REPLY='' + fi + done + if [[ -n $common ]]; then + (( ZSHZ_TILDE )) && common=${common/#${HOME}/\~} + (( $#output > 1 )) && printf "%-10s %s\n" 'common:' $common + fi + # -lt + if (( $+opts[-t] )); then + for x in ${(@On)output}; do + print -- $x + done + # -lr + elif (( $+opts[-r] )); then + for x in ${(@on)output}; do + print -- $x + done + # -l + else + for x in ${(@on)output}; do + print $x + done + fi + ;; + + *) + if (( ! ZSHZ_UNCOMMON )) && [[ -n $common ]]; then + _zshz_printv -- $common + else + _zshz_printv -- ${(P)match} + fi + ;; + esac + } + + ############################################################ + # Match a pattern by rank, time, or a combination of the + # two, and output the results as completions, a list, or a + # best match. + # + # Globals: + # ZSHZ + # ZSHZ_CASE + # ZSHZ_KEEP_DIRS + # ZSHZ_OWNER + # + # Arguments: + # #1 Pattern to match + # $2 Matching method (rank, time, or [default] frecency) + # $3 Output format (completion, list, or [default] store + # in REPLY + ############################################################ + _zshz_find_matches() { + setopt LOCAL_OPTIONS NO_EXTENDED_GLOB + + local fnd=$1 method=$2 format=$3 + + local -a existing_paths + local line dir path_field rank_field time_field rank dx escaped_path_field + local -A matches imatches + local best_match ibest_match hi_rank=-9999999999 ihi_rank=-9999999999 + + # Remove paths from database if they no longer exist + for line in $lines; do + if [[ ! -d ${line%%\|*} ]]; then + for dir in ${(@)ZSHZ_KEEP_DIRS}; do + if [[ ${line%%\|*} == ${dir}/* || + ${line%%\|*} == $dir || + $dir == '/' ]]; then + existing_paths+=( $line ) + fi + done + else + existing_paths+=( $line ) + fi + done + lines=( $existing_paths ) + + for line in $lines; do + path_field=${line%%\|*} + rank_field=${${line%\|*}#*\|} + time_field=${line##*\|} + + case $method in + rank) rank=$rank_field ;; + time) (( rank = time_field - EPOCHSECONDS )) ;; + *) + # Frecency routine + (( dx = EPOCHSECONDS - time_field )) + rank=$(( 10000 * rank_field * (3.75/((0.0001 * dx + 1) + 0.25)) )) + ;; + esac + + # Use spaces as wildcards + local q=${fnd//[[:space:]]/\*} + + # If $ZSHZ_TRAILING_SLASH is set, use path_field with a trailing slash for matching. + local path_field_normalized=$path_field + if (( ZSHZ_TRAILING_SLASH )); then + path_field_normalized=${path_field%/}/ + fi + + # If $ZSHZ_CASE is 'ignore', be case-insensitive. + # + # If it's 'smart', be case-insensitive unless the string to be matched + # includes capital letters. + # + # Otherwise, the default behavior of Zsh-z is to match case-sensitively if + # possible, then to fall back on a case-insensitive match if possible. + if [[ $ZSHZ_CASE == 'smart' && ${1:l} == $1 && + ${path_field_normalized:l} == ${~q:l} ]]; then + imatches[$path_field]=$rank + elif [[ $ZSHZ_CASE != 'ignore' && $path_field_normalized == ${~q} ]]; then + matches[$path_field]=$rank + elif [[ $ZSHZ_CASE != 'smart' && ${path_field_normalized:l} == ${~q:l} ]]; then + imatches[$path_field]=$rank + fi + + # Escape characters that would cause "invalid subscript" errors + # when accessing the associative array. + escaped_path_field=${path_field//'\'/'\\'} + escaped_path_field=${escaped_path_field//'`'/'\`'} + escaped_path_field=${escaped_path_field//'('/'\('} + escaped_path_field=${escaped_path_field//')'/'\)'} + escaped_path_field=${escaped_path_field//'['/'\['} + escaped_path_field=${escaped_path_field//']'/'\]'} + + if (( matches[$escaped_path_field] )) && + (( matches[$escaped_path_field] > hi_rank )); then + best_match=$path_field + hi_rank=${matches[$escaped_path_field]} + elif (( imatches[$escaped_path_field] )) && + (( imatches[$escaped_path_field] > ihi_rank )); then + ibest_match=$path_field + ihi_rank=${imatches[$escaped_path_field]} + ZSHZ[CASE_INSENSITIVE]=1 + fi + done + + # Return 1 when there are no matches + [[ -z $best_match && -z $ibest_match ]] && return 1 + + if [[ -n $best_match ]]; then + _zshz_output matches best_match $format + elif [[ -n $ibest_match ]]; then + _zshz_output imatches ibest_match $format + fi + } + + # THE MAIN ROUTINE + + local -A opts + + zparseopts -E -D -A opts -- \ + -add \ + -complete \ + c \ + e \ + h \ + -help \ + l \ + r \ + R \ + t \ + x + + if [[ $1 == '--' ]]; then + shift + elif [[ -n ${(M)@:#-*} && -z $compstate ]]; then + print "Improper option(s) given." + _zshz_usage + return 1 + fi + + local opt output_format method='frecency' fnd prefix req + + for opt in ${(k)opts}; do + case $opt in + --add) + [[ ! -d $* ]] && return 1 + local dir + # Cygwin and MSYS2 have a hard time with relative paths expressed from / + if [[ $OSTYPE == (cygwin|msys) && $PWD == '/' && $* != /* ]]; then + set -- "/$*" + fi + if (( ${ZSHZ_NO_RESOLVE_SYMLINKS:-${_Z_NO_RESOLVE_SYMLINKS}} )); then + dir=${*:a} + else + dir=${*:A} + fi + _zshz_add_or_remove_path --add "$dir" + return + ;; + --complete) + if [[ -s $datafile && ${ZSHZ_COMPLETION:-frecent} == 'legacy' ]]; then + _zshz_legacy_complete "$1" + return + fi + output_format='completion' + ;; + -c) [[ $* == ${PWD}/* || $PWD == '/' ]] || prefix="$PWD " ;; + -h|--help) + _zshz_usage + return + ;; + -l) output_format='list' ;; + -r) method='rank' ;; + -t) method='time' ;; + -x) + # Cygwin and MSYS2 have a hard time with relative paths expressed from / + if [[ $OSTYPE == (cygwin|msys) && $PWD == '/' && $* != /* ]]; then + set -- "/$*" + fi + _zshz_add_or_remove_path --remove $* + return + ;; + esac + done + req="$*" + fnd="$prefix$*" + + [[ -n $fnd && $fnd != "$PWD " ]] || { + [[ $output_format != 'completion' ]] && output_format='list' + } + + ######################################################### + # If $ZSHZ_ECHO == 1, display paths as you jump to them. + # If it is also the case that $ZSHZ_TILDE == 1, display + # the home directory as a tilde. + ######################################################### + _zshz_echo() { + if (( ZSHZ_ECHO )); then + if (( ZSHZ_TILDE )); then + print ${PWD/#${HOME}/\~} + else + print $PWD + fi + fi + } + + if [[ ${@: -1} == /* ]] && (( ! $+opts[-e] && ! $+opts[-l] )); then + # cd if possible; echo the new path if $ZSHZ_ECHO == 1 + [[ -d ${@: -1} ]] && builtin cd ${@: -1} && _zshz_echo && return + fi + + # With option -c, make sure query string matches beginning of matches; + # otherwise look for matches anywhere in paths + + # zpm-zsh/colors has a global $c, so we'll avoid math expressions here + if [[ ! -z ${(tP)opts[-c]} ]]; then + _zshz_find_matches "$fnd*" $method $output_format + else + _zshz_find_matches "*$fnd*" $method $output_format + fi + + local ret2=$? + + local cd + cd=$REPLY + + # New experimental "uncommon" behavior + # + # If the best choice at this point is something like /foo/bar/foo/bar, and the # search pattern is `bar', go to /foo/bar/foo/bar; but if the search pattern + # is `foo', go to /foo/bar/foo + if (( ZSHZ_UNCOMMON )) && [[ -n $cd ]]; then + if [[ -n $cd ]]; then + + # In the search pattern, replace spaces with * + local q=${fnd//[[:space:]]/\*} + q=${q%/} # Trailing slash has to be removed + + # As long as the best match is not case-insensitive + if (( ! ZSHZ[CASE_INSENSITIVE] )); then + # Count the number of characters in $cd that $q matches + local q_chars=$(( ${#cd} - ${#${cd//${~q}/}} )) + # Try dropping directory elements from the right; stop when it affects + # how many times the search pattern appears + until (( ( ${#cd:h} - ${#${${cd:h}//${~q}/}} ) != q_chars )); do + cd=${cd:h} + done + + # If the best match is case-insensitive + else + local q_chars=$(( ${#cd} - ${#${${cd:l}//${~${q:l}}/}} )) + until (( ( ${#cd:h} - ${#${${${cd:h}:l}//${~${q:l}}/}} ) != q_chars )); do + cd=${cd:h} + done + fi + + ZSHZ[CASE_INSENSITIVE]=0 + fi + fi + + if (( ret2 == 0 )) && [[ -n $cd ]]; then + if (( $+opts[-e] )); then # echo + (( ZSHZ_TILDE )) && cd=${cd/#${HOME}/\~} + print -- "$cd" + else + # cd if possible; echo the new path if $ZSHZ_ECHO == 1 + [[ -d $cd ]] && builtin cd "$cd" && _zshz_echo + fi + else + # if $req is a valid path, cd to it; echo the new path if $ZSHZ_ECHO == 1 + if ! (( $+opts[-e] || $+opts[-l] )) && [[ -d $req ]]; then + builtin cd "$req" && _zshz_echo + else + return $ret2 + fi + fi +} + +alias ${ZSHZ_CMD:-${_Z_CMD:-z}}='zshz 2>&1' + +############################################################ +# precmd - add path to datafile unless `z -x' has just been +# run +# +# Globals: +# ZSHZ +############################################################ +_zshz_precmd() { + # Do not add PWD to datafile when in HOME directory, or + # if `z -x' has just been run + [[ $PWD == "$HOME" ]] || (( ZSHZ[DIRECTORY_REMOVED] )) && return + + # Don't track directory trees excluded in ZSHZ_EXCLUDE_DIRS + local exclude + for exclude in ${(@)ZSHZ_EXCLUDE_DIRS:-${(@)_Z_EXCLUDE_DIRS}}; do + case $PWD in + ${exclude}|${exclude}/*) return ;; + esac + done + + # It appears that forking a subshell is so slow in Windows that it is better + # just to add the PWD to the datafile in the foreground + if [[ $OSTYPE == (cygwin|msys) ]]; then + zshz --add "$PWD" + else + (zshz --add "$PWD" &) + fi + + # See https://github.com/rupa/z/pull/247/commits/081406117ea42ccb8d159f7630cfc7658db054b6 + : $RANDOM +} + +############################################################ +# chpwd +# +# When the $PWD is removed from the datafile with `z -x', +# Zsh-z refrains from adding it again until the user has +# left the directory. +# +# Globals: +# ZSHZ +############################################################ +_zshz_chpwd() { + ZSHZ[DIRECTORY_REMOVED]=0 +} + +autoload -Uz add-zsh-hook + +add-zsh-hook precmd _zshz_precmd +add-zsh-hook chpwd _zshz_chpwd + +############################################################ +# Completion +############################################################ + +# Standarized $0 handling +# (See https://github.com/agkozak/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc) +0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}} +0=${${(M)0:#/*}:-$PWD/$0} + +(( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" ) + +############################################################ +# zsh-z functions +############################################################ +ZSHZ[FUNCTIONS]='_zshz_usage + _zshz_add_or_remove_path + _zshz_update_datafile + _zshz_legacy_complete + _zshz_printv + _zshz_find_common_root + _zshz_output + _zshz_find_matches + zshz + _zshz_precmd + _zshz_chpwd + _zshz' + +############################################################ +# Enable WARN_NESTED_VAR for functions listed in +# ZSHZ[FUNCTIONS] +############################################################ +(( ZSHZ_DEBUG )) && () { + if is-at-least 5.4.0; then + local x + for x in ${=ZSHZ[FUNCTIONS]}; do + functions -W $x + done + fi +} + +############################################################ +# Unload function +# +# See https://github.com/agkozak/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc#unload-fun +# +# Globals: +# ZSHZ +# ZSHZ_CMD +############################################################ +zsh-z_plugin_unload() { + emulate -L zsh + + add-zsh-hook -D precmd _zshz_precmd + add-zsh-hook -d chpwd _zshz_chpwd + + local x + for x in ${=ZSHZ[FUNCTIONS]}; do + (( ${+functions[$x]} )) && unfunction $x + done + + unset ZSHZ + + fpath=( "${(@)fpath:#${0:A:h}}" ) + + (( ${+aliases[${ZSHZ_CMD:-${_Z_CMD:-z}}]} )) && + unalias ${ZSHZ_CMD:-${_Z_CMD:-z}} + + unfunction $0 +} + +# vim: fdm=indent:ts=2:et:sts=2:sw=2: diff --git a/plugins/z/z.sh b/plugins/z/z.sh deleted file mode 100644 index 67f504e27..000000000 --- a/plugins/z/z.sh +++ /dev/null @@ -1,267 +0,0 @@ -# Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2 - -# maintains a jump-list of the directories you actually use -# -# INSTALL: -# * put something like this in your .bashrc/.zshrc: -# . /path/to/z.sh -# * cd around for a while to build up the db -# * PROFIT!! -# * optionally: -# set $_Z_CMD in .bashrc/.zshrc to change the command (default z). -# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z). -# set $_Z_MAX_SCORE lower to age entries out faster (default 9000). -# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution. -# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself. -# set $_Z_EXCLUDE_DIRS to an array of directories to exclude. -# set $_Z_OWNER to your username if you want use z while sudo with $HOME kept -# -# USE: -# * z foo # cd to most frecent dir matching foo -# * z foo bar # cd to most frecent dir matching foo and bar -# * z -r foo # cd to highest ranked dir matching foo -# * z -t foo # cd to most recently accessed dir matching foo -# * z -l foo # list matches instead of cd -# * z -e foo # echo the best match, don't cd -# * z -c foo # restrict matches to subdirs of $PWD -# * z -x # remove the current directory from the datafile -# * z -h # show a brief help message - -[ -d "${_Z_DATA:-$HOME/.z}" ] && { - echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory." -} - -_z() { - - local datafile="${_Z_DATA:-$HOME/.z}" - - # if symlink, dereference - [ -h "$datafile" ] && datafile=$(readlink "$datafile") - - # bail if we don't own ~/.z and $_Z_OWNER not set - [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return - - _z_dirs () { - [ -f "$datafile" ] || return - - local line - while read line; do - # only count directories - [ -d "${line%%\|*}" ] && echo "$line" - done < "$datafile" - return 0 - } - - # add entries - if [ "$1" = "--add" ]; then - shift - - # $HOME and / aren't worth matching - [ "$*" = "$HOME" -o "$*" = '/' ] && return - - # don't track excluded directory trees - if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then - local exclude - for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do - case "$*" in "$exclude"*) return;; esac - done - fi - - # maintain the data file - local tempfile="$datafile.$RANDOM" - local score=${_Z_MAX_SCORE:-9000} - _z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" ' - BEGIN { - rank[path] = 1 - time[path] = now - } - $2 >= 1 { - # drop ranks below 1 - if( $1 == path ) { - rank[$1] = $2 + 1 - time[$1] = now - } else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if( count > score ) { - # aging - for( x in rank ) print x "|" 0.99*rank[x] "|" time[x] - } else for( x in rank ) print x "|" rank[x] "|" time[x] - } - ' 2>/dev/null >| "$tempfile" - # do our best to avoid clobbering the datafile in a race condition. - if [ $? -ne 0 -a -f "$datafile" ]; then - env rm -f "$tempfile" - else - [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile" - env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile" - fi - - # tab completion - elif [ "$1" = "--complete" -a -s "$datafile" ]; then - _z_dirs | awk -v q="$2" -F"|" ' - BEGIN { - q = substr(q, 3) - if( q == tolower(q) ) imatch = 1 - gsub(/ /, ".*", q) - } - { - if( imatch ) { - if( tolower($1) ~ q ) print $1 - } else if( $1 ~ q ) print $1 - } - ' 2>/dev/null - - else - # list/go - local echo fnd last list opt typ - while [ "$1" ]; do case "$1" in - --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;; - -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in - c) fnd="^$PWD $fnd";; - e) echo=1;; - h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;; - l) list=1;; - r) typ="rank";; - t) typ="recent";; - x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; - esac; opt=${opt:1}; done;; - *) fnd="$fnd${fnd:+ }$1";; - esac; last=$1; [ "$#" -gt 0 ] && shift; done - [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1 - - # if we hit enter on a completion just go there - case "$last" in - # completions will always start with / - /*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;; - esac - - # no file yet - [ -f "$datafile" ] || return - - local cd - cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' - function frecent(rank, time) { - # relate frequency and time - dx = t - time - return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25))) - } - function output(matches, best_match, common) { - # list or return the desired directory - if( list ) { - if( common ) { - printf "%-10s %s\n", "common:", common > "/dev/stderr" - } - cmd = "sort -n >&2" - for( x in matches ) { - if( matches[x] ) { - printf "%-10s %s\n", matches[x], x | cmd - } - } - } else { - if( common && !typ ) best_match = common - print best_match - } - } - function common(matches) { - # find the common root of a list of matches, if it exists - for( x in matches ) { - if( matches[x] && (!short || length(x) < length(short)) ) { - short = x - } - } - if( short == "/" ) return - for( x in matches ) if( matches[x] && index(x, short) != 1 ) { - return - } - return short - } - BEGIN { - gsub(" ", ".*", q) - hi_rank = ihi_rank = -9999999999 - } - { - if( typ == "rank" ) { - rank = $2 - } else if( typ == "recent" ) { - rank = $3 - t - } else rank = frecent($2, $3) - if( $1 ~ q ) { - matches[$1] = rank - } else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank - if( matches[$1] && matches[$1] > hi_rank ) { - best_match = $1 - hi_rank = matches[$1] - } else if( imatches[$1] && imatches[$1] > ihi_rank ) { - ibest_match = $1 - ihi_rank = imatches[$1] - } - } - END { - # prefer case sensitive - if( best_match ) { - output(matches, best_match, common(matches)) - exit - } else if( ibest_match ) { - output(imatches, ibest_match, common(imatches)) - exit - } - exit(1) - } - ')" - - if [ "$?" -eq 0 ]; then - if [ "$cd" ]; then - if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi - fi - else - return $? - fi - fi -} - -alias ${_Z_CMD:-z}='_z 2>&1' - -[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P" - -if type compctl >/dev/null 2>&1; then - # zsh - [ "$_Z_NO_PROMPT_COMMAND" ] || { - # populate directory list, avoid clobbering any other precmds. - if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then - _z_precmd() { - (_z --add "${PWD:a}" &) - : $RANDOM - } - else - _z_precmd() { - (_z --add "${PWD:A}" &) - : $RANDOM - } - fi - [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || { - precmd_functions[$(($#precmd_functions+1))]=_z_precmd - } - } - _z_zsh_tab_completion() { - # tab completion - local compl - read -l compl - reply=(${(f)"$(_z --complete "$compl")"}) - } - compctl -U -K _z_zsh_tab_completion _z -elif type complete >/dev/null 2>&1; then - # bash - # tab completion - complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z} - [ "$_Z_NO_PROMPT_COMMAND" ] || { - # populate directory list. avoid clobbering other PROMPT_COMMANDs. - grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || { - PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);' - } - } -fi From 8487a5536d247927216dd22041c1c32bcd100256 Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 18 Oct 2022 19:38:47 +0200 Subject: [PATCH 08/77] fix(cli): avoid using `column` (#11271) --- lib/cli.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index f15bd6d63..fed00d21d 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -416,14 +416,14 @@ function _omz::plugin::list { if (( ${#custom_plugins} )); then print -P "%U%BCustom plugins%b%u:" - print -l ${(q-)custom_plugins} | column -x + print -lac ${(q-)custom_plugins} fi if (( ${#builtin_plugins} )); then (( ${#custom_plugins} )) && echo # add a line of separation print -P "%U%BBuilt-in plugins%b%u:" - print -l ${(q-)builtin_plugins} | column -x + print -lac ${(q-)builtin_plugins} fi } @@ -674,13 +674,13 @@ function _omz::theme::list { # Print custom themes if there are any if (( ${#custom_themes} )); then print -P "%U%BCustom themes%b%u:" - print -l ${(q-)custom_themes} | column -x + print -lac ${(q-)custom_themes} echo fi # Print built-in themes print -P "%U%BBuilt-in themes%b%u:" - print -l ${(q-)builtin_themes} | column -x + print -lac ${(q-)builtin_themes} } function _omz::theme::set { From 4e4961e60c6e4bb6a3bd30bc70576f00ea519930 Mon Sep 17 00:00:00 2001 From: Yuval Date: Tue, 18 Oct 2022 19:40:02 +0200 Subject: [PATCH 09/77] feat(aliases): add basic argument parsing (#10710) --- plugins/aliases/README.md | 6 ++++++ plugins/aliases/cheatsheet.py | 25 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index bfb6ab8c4..66fd84584 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -17,6 +17,12 @@ Requirements: Python needs to be installed. - `acs`: show all aliases by group. +- `acs -h/--help`: print help mesage. + - `acs `: filter aliases by `` and highlight. +- `acs -g /--group `. Multiple uses of the flag show all groups, + +- `acs --groups-only`: show only group names + ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png) diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index a7e3968b0..3362a6ab6 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -2,6 +2,7 @@ import sys import itertools import termcolor +import argparse def parse(line): left = line[0:line.find('=')].strip() @@ -26,7 +27,7 @@ def cheatsheet(lines): target_aliases.extend(group_list) return cheatsheet -def pretty_print_group(key, aliases, highlight=None): +def pretty_print_group(key, aliases, highlight=None, only_groupname=False): if len(aliases) == 0: return group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)]) @@ -35,21 +36,33 @@ def pretty_print_group(key, aliases, highlight=None): alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green') if highlight and len(highlight)>0: print (group_hl_formatter(key, highlight)) - print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases])) + if not only_groupname: + print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases])) else: print (group_formatter(key)) - print ('\n'.join([alias_formatter(alias) for alias in aliases])) + if not only_groupname: + print ('\n'.join([alias_formatter(alias) for alias in aliases])) print ('') -def pretty_print(cheatsheet, wfilter): +def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False): sorted_key = sorted(cheatsheet.keys()) for key in sorted_key: + if group_list and key not in group_list: + continue aliases = cheatsheet.get(key) if not wfilter: - pretty_print_group(key, aliases, wfilter) + pretty_print_group(key, aliases, wfilter, groups_only) else: pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter) if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Pretty print aliases.") + parser.add_argument('filter', nargs="*", help="search aliases matching string") + parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups") + parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups") + args = parser.parse_args() + lines = sys.stdin.readlines() - pretty_print(cheatsheet(lines), sys.argv[1] if len(sys.argv)>1 else None) + group_list = args.group_list or None + wfilter = " ".join(args.filter) or None + pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only) From a7d910c3a61d8599f748a8ddae59ecdd9424022a Mon Sep 17 00:00:00 2001 From: Shreem Asati <96364929+shreem-123@users.noreply.github.com> Date: Wed, 19 Oct 2022 11:57:54 +0530 Subject: [PATCH 10/77] chore: fix typo in CONTRIBUTING.md (#11273) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 59cf96012..e78bd8192 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -233,7 +233,7 @@ type(scope)!: subject Try to keep the first commit line short. This is harder to do using this commit style but try to be concise and if you need more space, you can use the commit body. Try to make sure that the commit -subject is clear and precise enough that users will know what change by just looking at the changelog. +subject is clear and precise enough that users will know what changed by just looking at the changelog. ---- From 0066280c3e971e1e45a9037f6d0b993dabcc3576 Mon Sep 17 00:00:00 2001 From: pomatory Date: Sun, 23 Oct 2022 02:52:26 +0800 Subject: [PATCH 11/77] fix(pip): fix `pipupall` error with `freeze` format (#11280) --- plugins/pip/pip.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 7eb2d2a35..90e39e118 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -94,12 +94,12 @@ alias pipreq="pip freeze > requirements.txt" # Install packages from requirements file alias pipir="pip install -r requirements.txt" -# Update all installed packages +# Upgrade all installed packages function pipupall { # non-GNU xargs does not support nor need `--no-run-if-empty` local xargs="xargs --no-run-if-empty" xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" - pip list --outdated --format freeze | cut -d= -f1 | ${=xargs} pip install --upgrade + pip list --outdated | awk 'NR > 2 { print $1 }' | ${=xargs} pip install --upgrade } # Uninstalled all installed packages From bb8a0aa2c1c54c3aeb3e703397ab050fd62e36e6 Mon Sep 17 00:00:00 2001 From: Zhong Ruoyu Date: Mon, 24 Oct 2022 18:07:12 +0800 Subject: [PATCH 12/77] fix(npm): ignore `rm` alias (#11222) --- plugins/npm/npm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 6c768d614..e0dcbf142 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,5 +1,5 @@ (( $+commands[npm] )) && { - rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" + command rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" _npm_completion() { local si=$IFS From 820b8bd40f19867d7811766f967d66faa5e5a818 Mon Sep 17 00:00:00 2001 From: Eric Hsieh Date: Wed, 26 Oct 2022 03:35:30 +0800 Subject: [PATCH 13/77] docs(autojump): fix outdated links and update description (#11289) --- plugins/asdf/README.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/asdf/README.md b/plugins/asdf/README.md index e8aa976bc..f047860e2 100644 --- a/plugins/asdf/README.md +++ b/plugins/asdf/README.md @@ -6,22 +6,25 @@ Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable ve ### Installation -1. Enable the plugin by adding it to your `plugins` definition in `~/.zshrc`. +1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following: + + ``` + git clone https://github.com/asdf-vm/asdf.git ~/.asdf + ``` + +2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`. ``` plugins=(asdf) ``` -2. [Install asdf](https://github.com/asdf-vm/asdf#setup) by running the following: - ``` - git clone https://github.com/asdf-vm/asdf.git ~/.asdf - ``` - ### Usage -See the [asdf usage documentation](https://github.com/asdf-vm/asdf#usage) for information on how to use asdf: +See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf: ``` -asdf plugin-add nodejs git@github.com:asdf-vm/asdf-nodejs.git -asdf install nodejs 5.9.1 +asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git +asdf install nodejs latest +asdf global nodejs latest +asdf local nodejs latest ``` From 49691b58b3c1fbe64b927ec88d5e9697f76e2a80 Mon Sep 17 00:00:00 2001 From: Paul S Date: Tue, 25 Oct 2022 20:39:58 +0100 Subject: [PATCH 14/77] feat(autojump): add support for macOS and nix (#11291) --- plugins/autojump/autojump.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 8593353b2..e11f231b6 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -12,6 +12,7 @@ autojump_paths=( /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) + /etc/profiles/per-user/$USER/bin/autojump # macOS Nix, Home Manager and flakes ) for file in $autojump_paths; do From 50a526f209a182add8a47e362e1c9a3bfd7c5af4 Mon Sep 17 00:00:00 2001 From: Pandey-utkarsh <91661580+Pandey-utkarsh@users.noreply.github.com> Date: Sun, 30 Oct 2022 17:51:35 +0530 Subject: [PATCH 15/77] chore: correct style in CONTRIBUTING.md (#11306) Corrected grammatically incorrect sentences, punctuations and typos for better readability. --- CONTRIBUTING.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e78bd8192..6c8b8446e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,13 +35,13 @@ you would make is not already covered. Please be so kind as to [search](#use-the-search-luke) for any open issue already covering your problem. -If you find one, comment on it so we can know there are more people experiencing it. +If you find one, comment on it, so we know more people are experiencing it. If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting) page for instructions on how to gather data to better debug your problem. Then, you can go ahead and create an issue with as much detail as you can provide. -It should include the data gathered as indicated above, along with: +It should include the data gathered as indicated above, along with the following: 1. How to reproduce the problem 2. What the correct behavior should be @@ -57,7 +57,7 @@ We will do our very best to help you. Please be so kind as to [search](#use-the-search-luke) for any open issue already covering your suggestion. -If you find one, comment on it so we can know there are more people supporting it. +If you find one, comment on it, so we know more people are supporting it. If not, you can go ahead and create an issue. Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle (starting with `@`) in your message. @@ -84,7 +84,7 @@ your [problem](#you-have-a-problem), and any pending/merged/rejected PR covering If the solution is already reported, try it out and +1 the pull request if the solution works ok. On the other hand, if you think your solution is better, post -it with a reference to the other one so we can have both solutions to compare. +it with reference to the other one so we can have both solutions to compare. If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle (starting with `@`) in your message. @@ -113,14 +113,14 @@ This has become an issue for two opposing reasons: - Some users want to have their personal aliases in Oh My Zsh. - Some users don't want any aliases at all and feel that there are too many. -Because of this, from now on we're requiring that new aliases follow these conditions: +Because of this, from now on, we require that new aliases follow these conditions: 1. They will be used by many people, not just a few. 2. The aliases will be used many times and for common tasks. 3. Prefer one generic alias over many specific ones. 4. When justifying the need for an alias, talk about workflows where you'll use it, preferably in combination with other aliases. -5. If there exists a command with the same name, look for a different alias name. +5. If a command with the same name exists, look for a different alias name. This list is not exhaustive! Please remember that your alias will be in the machines of many people, so it should be justified why they should have it. @@ -214,7 +214,7 @@ type(scope)!: subject ``` - `subject`: a brief description of the changes. This will be displayed in the changelog. If you need - to specify other details you can use the commit body but it won't be visible. + to specify other details, you can use the commit body, but it won't be visible. Formatting tricks: the commit subject may contain: @@ -231,8 +231,8 @@ type(scope)!: subject ### Style -Try to keep the first commit line short. This is harder to do using this commit style but try to be -concise and if you need more space, you can use the commit body. Try to make sure that the commit +Try to keep the first commit line short. It's harder to do using this commit style but try to be +concise, and if you need more space, you can use the commit body. Try to make sure that the commit subject is clear and precise enough that users will know what changed by just looking at the changelog. ---- From 239e2f9fcd3a3d469a2d6edfc33b57bf5c39c6a2 Mon Sep 17 00:00:00 2001 From: Lennart Ochel Date: Thu, 3 Nov 2022 18:30:30 +0100 Subject: [PATCH 16/77] ci: migrate to ProjectV2 GraphQL API (#11311) --- .github/workflows/project.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 999cc08e2..1aa69c279 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -27,24 +27,25 @@ jobs: gh api graphql -f query=' query($org: String!, $number: Int!) { organization(login: $org){ - projectNext(number: $number) { + projectV2(number: $number) { id fields(first:20) { nodes { - id - name + ... on ProjectV2Field { + id + name + } } } } } - } - ' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json # Parse project data cat >> $GITHUB_ENV <> $GITHUB_ENV @@ -108,23 +109,23 @@ jobs: $theme_field: ID! $theme_value: String! ) { - set_plugin: updateProjectNextItemField(input: { + set_plugin: updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item fieldId: $plugin_field value: $plugin_value }) { - projectNextItem { + projectV2Item { id } } - set_theme: updateProjectNextItemField(input: { + set_theme: updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item fieldId: $theme_field value: $theme_value }) { - projectNextItem { + projectV2Item { id } } @@ -133,4 +134,3 @@ jobs: -f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \ -f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \ --silent - From 5ddb5890118f577ac67bd9101ef66bcdd520c8d9 Mon Sep 17 00:00:00 2001 From: Qin Li <30631553+liblaf@users.noreply.github.com> Date: Fri, 4 Nov 2022 01:32:01 +0800 Subject: [PATCH 17/77] fix(brew): suppress error message of brew cask on Linux (#11302) --- plugins/brew/brew.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 41420b5b7..ea8900823 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -36,7 +36,7 @@ alias buf='brew upgrade --formula' function brews() { local formulae="$(brew leaves | xargs brew deps --installed --for-each)" - local casks="$(brew list --cask)" + local casks="$(brew list --cask 2>/dev/null)" local blue="$(tput setaf 4)" local bold="$(tput bold)" From 02972f801b4865c68a1045ce2455b3ac4a9d59ad Mon Sep 17 00:00:00 2001 From: Marco Eidinger Date: Thu, 3 Nov 2022 10:32:54 -0700 Subject: [PATCH 18/77] feat(swiftpm): update completion for Swift 5.7 (#11299) * feat(swiftpm): update completion for Swift 5.7 * chore(docs): fix typo --- plugins/swiftpm/README.md | 2 +- plugins/swiftpm/_swift | 1114 +++++++++++++++++++++++++------------ 2 files changed, 759 insertions(+), 357 deletions(-) diff --git a/plugins/swiftpm/README.md b/plugins/swiftpm/README.md index a722c03e4..223a607c1 100644 --- a/plugins/swiftpm/README.md +++ b/plugins/swiftpm/README.md @@ -2,7 +2,7 @@ ## Description -This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.1. +This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.7. To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`: diff --git a/plugins/swiftpm/_swift b/plugins/swiftpm/_swift index 3a923226d..51c9fffa0 100644 --- a/plugins/swiftpm/_swift +++ b/plugins/swiftpm/_swift @@ -1,474 +1,876 @@ #compdef swift local context state state_descr line +_swift_commandname=$words[1] typeset -A opt_args _swift() { - _arguments -C \ - '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ - '(-): :->command' \ - '(-)*:: :->arg' && return - + integer ret=1 + local -a args + args+=( + '(-h --help)'{-h,--help}'[Show help information.]' + '(-): :->command' + '(-)*:: :->arg' + ) + _arguments -w -s -S $args[@] && ret=0 case $state in (command) - local tools - tools=( - 'build:build sources into binary products' - 'run:build and run an executable product' - 'package:perform operations on Swift packages' - 'test:build and run tests' + local subcommands + subcommands=( + 'run:Build and run an executable product' + 'build:Build sources into binary products' + 'test:Build and run tests' + 'package:Perform operations on Swift packages' + 'help:Show subcommand help information.' ) - _alternative \ - 'tools:common:{_describe "tool" tools }' \ - 'compiler: :_swift_compiler' && _ret=0 + _describe "subcommand" subcommands ;; (arg) case ${words[1]} in - (build) - _swift_build - ;; (run) _swift_run ;; - (package) - _swift_package + (build) + _swift_build ;; (test) _swift_test ;; - (*) - _swift_compiler + (package) + _swift_package + ;; + (help) + _swift_help ;; esac ;; esac + + return ret } -_swift_dependency() { - local dependencies - dependencies=( $(swift package completion-tool list-dependencies) ) - _describe '' dependencies -} - -_swift_executable() { - local executables - executables=( $(swift package completion-tool list-executables) ) - _describe '' executables -} - -# Generates completions for swift build -# -# In the final compdef file, set the following file header: -# -# #compdef _swift_build -# local context state state_descr line -# typeset -A opt_args -_swift_build() { - arguments=( - "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: " - "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: " - "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: " - "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: " - "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}" - "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" - "(--chdir -C)"{--chdir,-C}"[]: :_files" - "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" - "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}" - "--disable-prefetching[]" - "--skip-update[Skip updating dependencies from their remote during a resolution]" - "--disable-sandbox[Disable using the sandbox when executing subprocesses]" - "--disable-package-manifest-caching[Disable caching Package.swift manifests]" - "--version[]" - "--destination[]: :_files" - "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" - "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" - "--static-swift-stdlib[Link Swift stdlib statically]" - "--force-resolved-versions[]" - "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" - "--enable-index-store[Enable indexing-while-building feature]" - "--disable-index-store[Disable indexing-while-building feature]" - "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" - "--enable-parseable-module-interfaces[]" - "--trace-resolver[]" - "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: " - "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]" - "--build-tests[Build both source and test targets]" - "--product[Build the specified product]:Build the specified product: " - "--target[Build the specified target]:Build the specified target: " - "--show-bin-path[Print the binary output path]" - ) - _arguments $arguments && return -} - -# Generates completions for swift run -# -# In the final compdef file, set the following file header: -# -# #compdef _swift_run -# local context state state_descr line -# typeset -A opt_args _swift_run() { - arguments=( - ":The executable to run:_swift_executable" - "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: " - "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: " - "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: " - "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: " - "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}" - "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" - "(--chdir -C)"{--chdir,-C}"[]: :_files" - "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" - "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}" - "--disable-prefetching[]" - "--skip-update[Skip updating dependencies from their remote during a resolution]" - "--disable-sandbox[Disable using the sandbox when executing subprocesses]" - "--disable-package-manifest-caching[Disable caching Package.swift manifests]" - "--version[]" - "--destination[]: :_files" - "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" - "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" - "--static-swift-stdlib[Link Swift stdlib statically]" - "--force-resolved-versions[]" - "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" - "--enable-index-store[Enable indexing-while-building feature]" - "--disable-index-store[Disable indexing-while-building feature]" - "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" - "--enable-parseable-module-interfaces[]" - "--trace-resolver[]" - "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: " - "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]" - "--skip-build[Skip building the executable product]" - "--build-tests[Build both source and test targets]" - "--repl[Launch Swift REPL for the package]" + integer ret=1 + local -a args + args+=( + '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/' + '--cache-path[Specify the shared cache directory path]:cache-path:_files -/' + '--config-path[Specify the shared configuration directory path]:config-path:_files -/' + '--security-path[Specify the shared security directory path]:security-path:_files -/' + '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/' + '--enable-dependency-cache[Use a shared cache when fetching dependencies]' + '--disable-dependency-cache[Use a shared cache when fetching dependencies]' + '--enable-build-manifest-caching' + '--disable-build-manifest-caching' + '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:' + '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]' + '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]' + '--disable-sandbox[Disable using the sandbox when executing subprocesses]' + '--enable-netrc[Load credentials from a .netrc file]' + '--disable-netrc[Load credentials from a .netrc file]' + '--netrc-file[Specify the .netrc file path.]:netrc-file:_files' + '--enable-keychain[Search credentials in macOS keychain]' + '--disable-keychain[Search credentials in macOS keychain]' + '--resolver-fingerprint-checking:resolver-fingerprint-checking:' + '--enable-prefetching' + '--disable-prefetching' + '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]' + '--skip-update[Skip updating dependencies from their remote during a resolution]' + '--disable-scm-to-registry-transformation[disable source control to registry transformation]' + '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]' + '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]' + '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)' + '-Xcc[Pass flag through to all C compiler invocations]:Xcc:' + '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:' + '-Xlinker[Pass flag through to all linker invocations]:Xlinker:' + '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:' + '--triple:triple:' + '--sdk:sdk:_files -/' + '--toolchain:toolchain:_files -/' + '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:' + '--auto-index-store[Enable or disable indexing-while-building feature]' + '--enable-index-store[Enable or disable indexing-while-building feature]' + '--disable-index-store[Enable or disable indexing-while-building feature]' + '--enable-parseable-module-interfaces' + '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:' + '--emit-swift-module-separately' + '--use-integrated-swift-driver' + '--experimental-explicit-module-build' + '--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]' + '--build-system:build-system:(native xcode)' + '--enable-dead-strip[Disable/enable dead code stripping by the linker]' + '--disable-dead-strip[Disable/enable dead code stripping by the linker]' + '--static-swift-stdlib[Link Swift stdlib statically]' + '--no-static-swift-stdlib[Link Swift stdlib statically]' + '--repl[Launch Swift REPL for the package]' + '--debugger[Launch the executable in a debugger session]' + '--run[Launch the executable with the provided arguments]' + '--skip-build[Skip building the executable product]' + '--build-tests[Build both source and test targets]' + ':executable:{local -a list; list=(${(f)"$(swift package completion-tool list-executables)"}); _describe '''' list}' + ':arguments:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_build() { + integer ret=1 + local -a args + args+=( + '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/' + '--cache-path[Specify the shared cache directory path]:cache-path:_files -/' + '--config-path[Specify the shared configuration directory path]:config-path:_files -/' + '--security-path[Specify the shared security directory path]:security-path:_files -/' + '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/' + '--enable-dependency-cache[Use a shared cache when fetching dependencies]' + '--disable-dependency-cache[Use a shared cache when fetching dependencies]' + '--enable-build-manifest-caching' + '--disable-build-manifest-caching' + '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:' + '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]' + '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]' + '--disable-sandbox[Disable using the sandbox when executing subprocesses]' + '--enable-netrc[Load credentials from a .netrc file]' + '--disable-netrc[Load credentials from a .netrc file]' + '--netrc-file[Specify the .netrc file path.]:netrc-file:_files' + '--enable-keychain[Search credentials in macOS keychain]' + '--disable-keychain[Search credentials in macOS keychain]' + '--resolver-fingerprint-checking:resolver-fingerprint-checking:' + '--enable-prefetching' + '--disable-prefetching' + '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]' + '--skip-update[Skip updating dependencies from their remote during a resolution]' + '--disable-scm-to-registry-transformation[disable source control to registry transformation]' + '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]' + '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]' + '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)' + '-Xcc[Pass flag through to all C compiler invocations]:Xcc:' + '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:' + '-Xlinker[Pass flag through to all linker invocations]:Xlinker:' + '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:' + '--triple:triple:' + '--sdk:sdk:_files -/' + '--toolchain:toolchain:_files -/' + '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:' + '--auto-index-store[Enable or disable indexing-while-building feature]' + '--enable-index-store[Enable or disable indexing-while-building feature]' + '--disable-index-store[Enable or disable indexing-while-building feature]' + '--enable-parseable-module-interfaces' + '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:' + '--emit-swift-module-separately' + '--use-integrated-swift-driver' + '--experimental-explicit-module-build' + '--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]' + '--build-system:build-system:(native xcode)' + '--enable-dead-strip[Disable/enable dead code stripping by the linker]' + '--disable-dead-strip[Disable/enable dead code stripping by the linker]' + '--static-swift-stdlib[Link Swift stdlib statically]' + '--no-static-swift-stdlib[Link Swift stdlib statically]' + '--build-tests[Build both source and test targets]' + '--show-bin-path[Print the binary output path]' + '--target[Build the specified target]:target:' + '--product[Build the specified product]:product:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_test() { + integer ret=1 + local -a args + args+=( + '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/' + '--cache-path[Specify the shared cache directory path]:cache-path:_files -/' + '--config-path[Specify the shared configuration directory path]:config-path:_files -/' + '--security-path[Specify the shared security directory path]:security-path:_files -/' + '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/' + '--enable-dependency-cache[Use a shared cache when fetching dependencies]' + '--disable-dependency-cache[Use a shared cache when fetching dependencies]' + '--enable-build-manifest-caching' + '--disable-build-manifest-caching' + '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:' + '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]' + '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]' + '--disable-sandbox[Disable using the sandbox when executing subprocesses]' + '--enable-netrc[Load credentials from a .netrc file]' + '--disable-netrc[Load credentials from a .netrc file]' + '--netrc-file[Specify the .netrc file path.]:netrc-file:_files' + '--enable-keychain[Search credentials in macOS keychain]' + '--disable-keychain[Search credentials in macOS keychain]' + '--resolver-fingerprint-checking:resolver-fingerprint-checking:' + '--enable-prefetching' + '--disable-prefetching' + '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]' + '--skip-update[Skip updating dependencies from their remote during a resolution]' + '--disable-scm-to-registry-transformation[disable source control to registry transformation]' + '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]' + '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]' + '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)' + '-Xcc[Pass flag through to all C compiler invocations]:Xcc:' + '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:' + '-Xlinker[Pass flag through to all linker invocations]:Xlinker:' + '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:' + '--triple:triple:' + '--sdk:sdk:_files -/' + '--toolchain:toolchain:_files -/' + '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:' + '--auto-index-store[Enable or disable indexing-while-building feature]' + '--enable-index-store[Enable or disable indexing-while-building feature]' + '--disable-index-store[Enable or disable indexing-while-building feature]' + '--enable-parseable-module-interfaces' + '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:' + '--emit-swift-module-separately' + '--use-integrated-swift-driver' + '--experimental-explicit-module-build' + '--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]' + '--build-system:build-system:(native xcode)' + '--enable-dead-strip[Disable/enable dead code stripping by the linker]' + '--disable-dead-strip[Disable/enable dead code stripping by the linker]' + '--static-swift-stdlib[Link Swift stdlib statically]' + '--no-static-swift-stdlib[Link Swift stdlib statically]' + '--skip-build[Skip building the test target]' + '--parallel[Run the tests in parallel.]' + '--num-workers[Number of tests to execute in parallel.]:num-workers:' + '(--list-tests -l)'{--list-tests,-l}'[Lists test methods in specifier format]' + '--show-codecov-path[Print the path of the exported code coverage JSON file]' + '(-s --specifier)'{-s,--specifier}':specifier:' + '--filter[Run test cases matching regular expression, Format: . or ./]:filter:' + '--skip[Skip test cases matching regular expression, Example: --skip PerformanceTests]:skip:' + '--xunit-output[Path where the xUnit xml file should be generated.]:xunit-output:_files -/' + '--test-product[Test the specified product.]:test-product:' + '--enable-testable-imports[Enable or disable testable imports. Enabled by default.]' + '--disable-testable-imports[Enable or disable testable imports. Enabled by default.]' + '--enable-code-coverage[Enable code coverage]' + '--disable-code-coverage[Enable code coverage]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret } -# Generates completions for swift package -# -# In the final compdef file, set the following file header: -# -# #compdef _swift_package -# local context state state_descr line -# typeset -A opt_args _swift_package() { - arguments=( - "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: " - "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: " - "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: " - "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: " - "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}" - "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" - "(--chdir -C)"{--chdir,-C}"[]: :_files" - "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" - "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}" - "--disable-prefetching[]" - "--skip-update[Skip updating dependencies from their remote during a resolution]" - "--disable-sandbox[Disable using the sandbox when executing subprocesses]" - "--disable-package-manifest-caching[Disable caching Package.swift manifests]" - "--version[]" - "--destination[]: :_files" - "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" - "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" - "--static-swift-stdlib[Link Swift stdlib statically]" - "--force-resolved-versions[]" - "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" - "--enable-index-store[Enable indexing-while-building feature]" - "--disable-index-store[Disable indexing-while-building feature]" - "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" - "--enable-parseable-module-interfaces[]" - "--trace-resolver[]" - "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: " - "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]" + integer ret=1 + local -a args + args+=( + '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/' + '--cache-path[Specify the shared cache directory path]:cache-path:_files -/' + '--config-path[Specify the shared configuration directory path]:config-path:_files -/' + '--security-path[Specify the shared security directory path]:security-path:_files -/' + '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/' + '--enable-dependency-cache[Use a shared cache when fetching dependencies]' + '--disable-dependency-cache[Use a shared cache when fetching dependencies]' + '--enable-build-manifest-caching' + '--disable-build-manifest-caching' + '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:' + '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]' + '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]' + '--disable-sandbox[Disable using the sandbox when executing subprocesses]' + '--enable-netrc[Load credentials from a .netrc file]' + '--disable-netrc[Load credentials from a .netrc file]' + '--netrc-file[Specify the .netrc file path.]:netrc-file:_files' + '--enable-keychain[Search credentials in macOS keychain]' + '--disable-keychain[Search credentials in macOS keychain]' + '--resolver-fingerprint-checking:resolver-fingerprint-checking:' + '--enable-prefetching' + '--disable-prefetching' + '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]' + '--skip-update[Skip updating dependencies from their remote during a resolution]' + '--disable-scm-to-registry-transformation[disable source control to registry transformation]' + '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]' + '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]' + '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)' + '-Xcc[Pass flag through to all C compiler invocations]:Xcc:' + '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:' + '-Xlinker[Pass flag through to all linker invocations]:Xlinker:' + '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:' + '--triple:triple:' + '--sdk:sdk:_files -/' + '--toolchain:toolchain:_files -/' + '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:' + '--auto-index-store[Enable or disable indexing-while-building feature]' + '--enable-index-store[Enable or disable indexing-while-building feature]' + '--disable-index-store[Enable or disable indexing-while-building feature]' + '--enable-parseable-module-interfaces' + '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:' + '--emit-swift-module-separately' + '--use-integrated-swift-driver' + '--experimental-explicit-module-build' + '--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]' + '--build-system:build-system:(native xcode)' + '--enable-dead-strip[Disable/enable dead code stripping by the linker]' + '--disable-dead-strip[Disable/enable dead code stripping by the linker]' + '--static-swift-stdlib[Link Swift stdlib statically]' + '--no-static-swift-stdlib[Link Swift stdlib statically]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' '(-): :->command' '(-)*:: :->arg' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 case $state in (command) - local modes - modes=( - 'completion-tool:Completion tool (for shell completions)' - 'dump-package:Print parsed Package.swift as JSON' - 'describe:Describe the current package' + local subcommands + subcommands=( 'clean:Delete build artifacts' - 'show-dependencies:Print the resolved dependency graph' - 'init:Initialize a new package' - 'unedit:Remove a package from editable mode' - 'tools-version:Manipulate tools version of the current package' - 'fetch:' - 'resolve:Resolve package dependencies' + 'purge-cache:Purge the global repository cache.' 'reset:Reset the complete cache/build directory' - 'generate-xcodeproj:Generates an Xcode project' - 'edit:Put a package in editable mode' - 'config:Manipulate configuration of the package' 'update:Update package dependencies' + 'describe:Describe the current package' + 'init:Initialize a new package' + '_format:' + 'diagnose-api-breaking-changes:Diagnose API-breaking changes to Swift modules in a package' + 'experimental-api-diff:Deprecated - use `swift package diagnose-api-breaking-changes` instead' + 'dump-symbol-graph:Dump Symbol Graph' + 'dump-pif:' + 'dump-package:Print parsed Package.swift as JSON' + 'edit:Put a package in editable mode' + 'unedit:Remove a package from editable mode' + 'config:Manipulate configuration of the package' + 'resolve:Resolve package dependencies' + 'fetch:' + 'show-dependencies:Print the resolved dependency graph' + 'tools-version:Manipulate tools version of the current package' + 'generate-xcodeproj:Generates an Xcode project. This command will be deprecated soon.' + 'compute-checksum:Compute the checksum for a binary artifact.' + 'archive-source:Create a source archive for the package' + 'completion-tool:Completion tool (for shell completions)' + 'plugin:Invoke a command plugin or perform other actions on command plugins' + 'default-command:' ) - _describe "mode" modes + _describe "subcommand" subcommands ;; (arg) case ${words[1]} in - (completion-tool) - _swift_package_completion-tool - ;; - (dump-package) - _swift_package_dump-package - ;; - (describe) - _swift_package_describe - ;; (clean) _swift_package_clean ;; - (show-dependencies) - _swift_package_show-dependencies - ;; - (init) - _swift_package_init - ;; - (unedit) - _swift_package_unedit - ;; - (tools-version) - _swift_package_tools-version - ;; - (fetch) - _swift_package_fetch - ;; - (resolve) - _swift_package_resolve + (purge-cache) + _swift_package_purge-cache ;; (reset) _swift_package_reset ;; - (generate-xcodeproj) - _swift_package_generate-xcodeproj + (update) + _swift_package_update + ;; + (describe) + _swift_package_describe + ;; + (init) + _swift_package_init + ;; + (_format) + _swift_package__format + ;; + (diagnose-api-breaking-changes) + _swift_package_diagnose-api-breaking-changes + ;; + (experimental-api-diff) + _swift_package_experimental-api-diff + ;; + (dump-symbol-graph) + _swift_package_dump-symbol-graph + ;; + (dump-pif) + _swift_package_dump-pif + ;; + (dump-package) + _swift_package_dump-package ;; (edit) _swift_package_edit ;; + (unedit) + _swift_package_unedit + ;; (config) _swift_package_config ;; - (update) - _swift_package_update + (resolve) + _swift_package_resolve + ;; + (fetch) + _swift_package_fetch + ;; + (show-dependencies) + _swift_package_show-dependencies + ;; + (tools-version) + _swift_package_tools-version + ;; + (generate-xcodeproj) + _swift_package_generate-xcodeproj + ;; + (compute-checksum) + _swift_package_compute-checksum + ;; + (archive-source) + _swift_package_archive-source + ;; + (completion-tool) + _swift_package_completion-tool + ;; + (plugin) + _swift_package_plugin + ;; + (default-command) + _swift_package_default-command ;; esac ;; esac -} -_swift_package_completion-tool() { - arguments=( - ": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}" - ) - _arguments $arguments && return -} - -_swift_package_dump-package() { - arguments=( - ) - _arguments $arguments && return -} - -_swift_package_describe() { - arguments=( - "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}" - ) - _arguments $arguments && return + return ret } _swift_package_clean() { - arguments=( + integer ret=1 + local -a args + args+=( + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret } -_swift_package_show-dependencies() { - arguments=( - "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}" +_swift_package_purge-cache() { + integer ret=1 + local -a args + args+=( + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return -} + _arguments -w -s -S $args[@] && ret=0 -_swift_package_init() { - arguments=( - "--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}" - "--name[Provide custom package name]:Provide custom package name: " - ) - _arguments $arguments && return -} - -_swift_package_unedit() { - arguments=( - ":The name of the package to unedit:_swift_dependency" - "--force[Unedit the package even if it has uncommitted and unpushed changes.]" - ) - _arguments $arguments && return -} - -_swift_package_tools-version() { - arguments=( - "--set[Set tools version of package to the given value]:Set tools version of package to the given value: " - "--set-current[Set tools version of package to the current tools version in use]" - ) - _arguments $arguments && return -} - -_swift_package_fetch() { - arguments=( - ) - _arguments $arguments && return -} - -_swift_package_resolve() { - arguments=( - ":The name of the package to resolve:_swift_dependency" - "--version[The version to resolve at]:The version to resolve at: " - "--branch[The branch to resolve at]:The branch to resolve at: " - "--revision[The revision to resolve at]:The revision to resolve at: " - ) - _arguments $arguments && return + return ret } _swift_package_reset() { - arguments=( + integer ret=1 + local -a args + args+=( + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret } -_swift_package_generate-xcodeproj() { - arguments=( - "--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files" - "--enable-code-coverage[Enable code coverage in the generated project]" - "--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files" - "--legacy-scheme-generator[Use the legacy scheme generator]" - "--watch[Watch for changes to the Package manifest to regenerate the Xcode project]" - "--skip-extra-files[Do not add file references for extra files to the generated Xcode project]" +_swift_package_update() { + integer ret=1 + local -a args + args+=( + '(--dry-run -n)'{--dry-run,-n}'[Display the list of dependencies that can be updated]' + ':packages:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_describe() { + integer ret=1 + local -a args + args+=( + '--type[json | text]:type:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_init() { + integer ret=1 + local -a args + args+=( + '--type[Package type: empty | library | executable | system-module | manifest]:type:' + '--name[Provide custom package name]:name:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package__format() { + integer ret=1 + local -a args + args+=( + ':swift-format-flags:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_diagnose-api-breaking-changes() { + integer ret=1 + local -a args + args+=( + '--breakage-allowlist-path[The path to a text file containing breaking changes which should be ignored by the API comparison. Each ignored breaking change in the file should appear on its own line and contain the exact message to be ignored (e.g. '"'"'API breakage: func foo() has been removed'"'"').]:breakage-allowlist-path:_files -/' + ':treeish:' + '--products[One or more products to include in the API comparison. If present, only the specified products (and any targets specified using `--targets`) will be compared.]:products:' + '--targets[One or more targets to include in the API comparison. If present, only the specified targets (and any products specified using `--products`) will be compared.]:targets:' + '--baseline-dir[The path to a directory used to store API baseline files. If unspecified, a temporary directory will be used.]:baseline-dir:_files -/' + '--regenerate-baseline[Regenerate the API baseline, even if an existing one is available.]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_experimental-api-diff() { + integer ret=1 + local -a args + args+=( + ':args:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_dump-symbol-graph() { + integer ret=1 + local -a args + args+=( + '--pretty-print[Pretty-print the output JSON.]' + '--skip-synthesized-members[Skip members inherited through classes or default implementations.]' + '--minimum-access-level[Include symbols with this access level or more. Possible values: private | fileprivate | internal | public | open]:minimum-access-level:(private fileprivate internal public open)' + '--skip-inherited-docs[Skip emitting doc comments for members inherited through classes or default implementations.]' + '--include-spi-symbols[Add symbols with SPI information to the symbol graph.]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_dump-pif() { + integer ret=1 + local -a args + args+=( + '--preserve-structure[Preserve the internal structure of PIF]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_dump-package() { + integer ret=1 + local -a args + args+=( + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret } _swift_package_edit() { - arguments=( - ":The name of the package to edit:_swift_dependency" - "--revision[The revision to edit]:The revision to edit: " - "--branch[The branch to create]:The branch to create: " - "--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files" + integer ret=1 + local -a args + args+=( + '--revision[The revision to edit]:revision:' + '--branch[The branch to create]:branch:' + '--path[Create or use the checkout at this path]:path:_files -/' + ':package-name:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_unedit() { + integer ret=1 + local -a args + args+=( + '--force[Unedit the package even if it has uncommitted and unpushed changes]' + ':package-name:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret } _swift_package_config() { - arguments=( + integer ret=1 + local -a args + args+=( + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' '(-): :->command' '(-)*:: :->arg' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 case $state in (command) - local modes - modes=( + local subcommands + subcommands=( + 'set-mirror:Set a mirror for a dependency' 'unset-mirror:Remove an existing mirror' 'get-mirror:Print mirror configuration for the given package dependency' - 'set-mirror:Set a mirror for a dependency' ) - _describe "mode" modes + _describe "subcommand" subcommands ;; (arg) case ${words[1]} in + (set-mirror) + _swift_package_config_set-mirror + ;; (unset-mirror) _swift_package_config_unset-mirror ;; (get-mirror) _swift_package_config_get-mirror ;; - (set-mirror) - _swift_package_config_set-mirror - ;; esac ;; esac -} -_swift_package_config_unset-mirror() { - arguments=( - "--package-url[The package dependency url]:The package dependency url: " - "--mirror-url[The mirror url]:The mirror url: " - ) - _arguments $arguments && return -} - -_swift_package_config_get-mirror() { - arguments=( - "--package-url[The package dependency url]:The package dependency url: " - ) - _arguments $arguments && return + return ret } _swift_package_config_set-mirror() { - arguments=( - "--package-url[The package dependency url]:The package dependency url: " - "--mirror-url[The mirror url]:The mirror url: " + integer ret=1 + local -a args + args+=( + '--package-url[The package dependency url]:package-url:' + '--original-url[The original url]:original-url:' + '--mirror-url[The mirror url]:mirror-url:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret } -_swift_package_update() { - arguments=( +_swift_package_config_unset-mirror() { + integer ret=1 + local -a args + args+=( + '--package-url[The package dependency url]:package-url:' + '--original-url[The original url]:original-url:' + '--mirror-url[The mirror url]:mirror-url:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret } -# Generates completions for swift test -# -# In the final compdef file, set the following file header: -# -# #compdef _swift_test -# local context state state_descr line -# typeset -A opt_args -_swift_test() { - arguments=( - "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: " - "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: " - "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: " - "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: " - "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}" - "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" - "(--chdir -C)"{--chdir,-C}"[]: :_files" - "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" - "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}" - "--disable-prefetching[]" - "--skip-update[Skip updating dependencies from their remote during a resolution]" - "--disable-sandbox[Disable using the sandbox when executing subprocesses]" - "--disable-package-manifest-caching[Disable caching Package.swift manifests]" - "--version[]" - "--destination[]: :_files" - "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" - "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" - "--static-swift-stdlib[Link Swift stdlib statically]" - "--force-resolved-versions[]" - "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" - "--enable-index-store[Enable indexing-while-building feature]" - "--disable-index-store[Disable indexing-while-building feature]" - "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" - "--enable-parseable-module-interfaces[]" - "--trace-resolver[]" - "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: " - "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]" - "--skip-build[Skip building the test target]" - "(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]" - "--generate-linuxmain[Generate LinuxMain.swift entries for the package]" - "--parallel[Run the tests in parallel.]" - "--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: " - "(--specifier -s)"{--specifier,-s}"[]: : " - "--xunit-output[]: :_files" - "--filter[Run test cases matching regular expression, Format: . or ./]:Run test cases matching regular expression, Format: . or ./: " - "--enable-code-coverage[Test with code coverage enabled]" +_swift_package_config_get-mirror() { + integer ret=1 + local -a args + args+=( + '--package-url[The package dependency url]:package-url:' + '--original-url[The original url]:original-url:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' ) - _arguments $arguments && return + _arguments -w -s -S $args[@] && ret=0 + + return ret } -_swift_compiler() { +_swift_package_resolve() { + integer ret=1 + local -a args + args+=( + '--version[The version to resolve at]:version:' + '--branch[The branch to resolve at]:branch:' + '--revision[The revision to resolve at]:revision:' + ':package-name:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_fetch() { + integer ret=1 + local -a args + args+=( + '--version[The version to resolve at]:version:' + '--branch[The branch to resolve at]:branch:' + '--revision[The revision to resolve at]:revision:' + ':package-name:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_show-dependencies() { + integer ret=1 + local -a args + args+=( + '--format[text | dot | json | flatlist]:format:' + '(--output-path -o)'{--output-path,-o}'[The absolute or relative path to output the resolved dependency graph.]:output-path:_files -/' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_tools-version() { + integer ret=1 + local -a args + args+=( + '--set-current[Set tools version of package to the current tools version in use]' + '--set[Set tools version of package to the given value]:set:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_generate-xcodeproj() { + integer ret=1 + local -a args + args+=( + '--xcconfig-overrides[Path to xcconfig file]:xcconfig-overrides:_files' + '--output[Path where the Xcode project should be generated]:output:_files -/' + '--legacy-scheme-generator[Use the legacy scheme generator]' + '--watch[Watch for changes to the Package manifest to regenerate the Xcode project]' + '--skip-extra-files[Do not add file references for extra files to the generated Xcode project]' + '--enable-code-coverage[Enable code coverage]' + '--disable-code-coverage[Enable code coverage]' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_compute-checksum() { + integer ret=1 + local -a args + args+=( + ':path:_files -/' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_archive-source() { + integer ret=1 + local -a args + args+=( + '(-o --output)'{-o,--output}'[The absolute or relative path for the generated source archive]:output:_files -/' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_completion-tool() { + integer ret=1 + local -a args + args+=( + ':mode:(generate-bash-script generate-zsh-script generate-fish-script list-dependencies list-executables list-snippets)' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_plugin() { + integer ret=1 + local -a args + args+=( + '--list[List the available command plugins]' + '--allow-writing-to-package-directory[Allow the plugin to write to the package directory]' + '--allow-writing-to-directory[Allow the plugin to write to an additional directory]:allow-writing-to-directory:' + ':command:' + ':arguments:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_package_default-command() { + integer ret=1 + local -a args + args+=( + '--allow-writing-to-package-directory[Allow the plugin to write to the package directory]' + '--allow-writing-to-directory[Allow the plugin to write to an additional directory]:allow-writing-to-directory:' + ':remaining:' + '--version[Show the version.]' + '(-help -h --help)'{-help,-h,--help}'[Show help information.]' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + +_swift_help() { + integer ret=1 + local -a args + args+=( + ':subcommands:' + ) + _arguments -w -s -S $args[@] && ret=0 + + return ret +} + + +_custom_completion() { + local completions=("${(@f)$($*)}") + _describe '' completions } _swift From b3b336b0f95644ceda7758871191cdf040b897b2 Mon Sep 17 00:00:00 2001 From: Andrew Wu Date: Fri, 4 Nov 2022 01:34:28 +0800 Subject: [PATCH 19/77] feat(fzf): fix MacPorts auto-completion file location. (#11305) --- plugins/fzf/fzf.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index a946cf762..60ae0c765 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -178,7 +178,7 @@ function fzf_setup_using_macports() { (( $+commands[fzf] )) || return 1 # The fzf-zsh-completion package installs the auto-completion in - local completions="/opt/local/share/zsh/site-functions/fzf" + local completions="/opt/local/share/fzf/shell/completion.zsh" # The fzf-zsh-completion package installs the key-bindings file in local key_bindings="/opt/local/share/fzf/shell/key-bindings.zsh" From 1342459b153576429382aed34ee5753f85bf3420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 4 Nov 2022 19:16:54 +0100 Subject: [PATCH 20/77] ci: fix update of plugin or theme fields See [1] for the reference of value field (ProjectV2FieldValue type), and [2] for sample application code. [1] https://docs.github.com/en/graphql/reference/input-objects#projectv2fieldvalue [2] https://docs.github.com/en/enterprise-cloud@latest/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions#example-workflow-authenticating-with-a-github-app --- .github/workflows/project.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 1aa69c279..1d961d8c0 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -113,7 +113,9 @@ jobs: projectId: $project itemId: $item fieldId: $plugin_field - value: $plugin_value + value: { + text: $plugin_value + } }) { projectV2Item { id @@ -123,7 +125,9 @@ jobs: projectId: $project itemId: $item fieldId: $theme_field - value: $theme_value + value: { + text: $theme_value + } }) { projectV2Item { id From 9f2bbebdf78322ab11a4cc57e2932fcbf6fb3fa8 Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Fri, 4 Nov 2022 11:34:02 -0700 Subject: [PATCH 21/77] docs: fix some capitalization typos(#11293) --- plugins/coffee/_coffee | 2 +- plugins/docker-machine/_docker-machine | 4 ++-- plugins/frontend-search/_frontend | 2 +- plugins/httpie/_httpie | 2 +- plugins/kitchen/_kitchen | 2 +- plugins/pod/_pod | 2 +- plugins/rails/_rails | 2 +- plugins/ripgrep/_ripgrep | 2 +- plugins/scala/_scala | 2 +- plugins/xcode/xcode.plugin.zsh | 2 +- themes/refined.zsh-theme | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/coffee/_coffee b/plugins/coffee/_coffee index e2814f7ba..a771f5204 100644 --- a/plugins/coffee/_coffee +++ b/plugins/coffee/_coffee @@ -1,6 +1,6 @@ #compdef coffee # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# Copyright (c) 2011 GitHub zsh-users - https://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/docker-machine/_docker-machine b/plugins/docker-machine/_docker-machine index fbd36d7c6..17bcd3598 100644 --- a/plugins/docker-machine/_docker-machine +++ b/plugins/docker-machine/_docker-machine @@ -335,9 +335,9 @@ _docker-machine() { '--tls-ca-key[Private key to generate certificates]:file:_files' \ '--tls-client-cert[Client cert to use for TLS]:file:_files' \ '--tls-client-key[Private key used in client TLS auth]:file:_files' \ - '--github-api-token[Token to use for requests to the Github API]' \ + '--github-api-token[Token to use for requests to the GitHub API]' \ '--native-ssh[Use the native (Go-based) SSH implementation.]' \ - '--bugsnag-api-token[BugSnag API token for crash reporting]' \ + '--bugsnag-api-token[Bugsnag API token for crash reporting]' \ '(- :)'{-v,--version}'[Print the version]' \ "(-): :->command" \ "(-)*:: :->option-or-argument" && ret=0 diff --git a/plugins/frontend-search/_frontend b/plugins/frontend-search/_frontend index 15f8d239d..aca4920d7 100644 --- a/plugins/frontend-search/_frontend +++ b/plugins/frontend-search/_frontend @@ -37,7 +37,7 @@ function _frontend() { 'lodash: Search in Lo-Dash website' 'mdn: Search in MDN website' 'nodejs: Search in NodeJS website' - 'npmjs: Search in NPMJS website' + 'npmjs: Search in npmjs website' 'packagephobia: Search in Packagephobia website' 'qunit: Search in Qunit website' 'reactjs: Search in React website' diff --git a/plugins/httpie/_httpie b/plugins/httpie/_httpie index 4d702ef60..11bc8e1f8 100644 --- a/plugins/httpie/_httpie +++ b/plugins/httpie/_httpie @@ -1,6 +1,6 @@ #compdef http # ------------------------------------------------------------------------------ -# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/kitchen/_kitchen b/plugins/kitchen/_kitchen index d93d93d78..64c01e395 100644 --- a/plugins/kitchen/_kitchen +++ b/plugins/kitchen/_kitchen @@ -1,6 +1,6 @@ #compdef kitchen # ------------------------------------------------------------------------------ -# Copyright (c) 2014 Github zsh-users - https://github.com/zsh-users +# Copyright (c) 2014 GitHub zsh-users - https://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/pod/_pod b/plugins/pod/_pod index 80d23daad..d560129db 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -6,7 +6,7 @@ # ----------------------------------------------------------------------------- # FILE: _pod -# DESCRIPTION: Cocoapods (0.33.1) autocomplete plugin for Oh-My-Zsh +# DESCRIPTION: CocoaPods (0.33.1) autocomplete plugin for Oh-My-Zsh # https://cocoapods.org # Generated with `pod --completion-script # AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch) diff --git a/plugins/rails/_rails b/plugins/rails/_rails index 6dc85d458..ac90d45cc 100644 --- a/plugins/rails/_rails +++ b/plugins/rails/_rails @@ -1,6 +1,6 @@ #compdef rails # ------------------------------------------------------------------------------ -# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2016 GitHub zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/ripgrep/_ripgrep b/plugins/ripgrep/_ripgrep index 31bc697c7..a93a8b8eb 100644 --- a/plugins/ripgrep/_ripgrep +++ b/plugins/ripgrep/_ripgrep @@ -591,7 +591,7 @@ _rg "$@" ################################################################################ # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/scala/_scala b/plugins/scala/_scala index ba7ac3874..b4e834e2f 100644 --- a/plugins/scala/_scala +++ b/plugins/scala/_scala @@ -1,6 +1,6 @@ #compdef scala scalac # ------------------------------------------------------------------------------ -# Copyright (c) 2012 Github zsh-users - https://github.com/zsh-users +# Copyright (c) 2012 GitHub zsh-users - https://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 3bd12cdec..5d1f901a3 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -31,7 +31,7 @@ function xx { open -a "Xcode.app" "$@" } -# "XCode-SELect by Version" - select Xcode by just version number +# "Xcode-Select by Version" - select Xcode by just version number # Uses naming convention: # - different versions of Xcode are named Xcode-.app or stored # in a folder named Xcode- diff --git a/themes/refined.zsh-theme b/themes/refined.zsh-theme index 5e2de7a87..2b55cfb0c 100644 --- a/themes/refined.zsh-theme +++ b/themes/refined.zsh-theme @@ -11,11 +11,11 @@ # more about both of these fantastic two people here: # # Sindre Sorhus -# Github: https://github.com/sindresorhus +# GitHub: https://github.com/sindresorhus # Twitter: https://twitter.com/sindresorhus # # Julien Nicoulaud -# Github: https://github.com/nicoulaj +# GitHub: https://github.com/nicoulaj # Twitter: https://twitter.com/nicoulaj # # ------------------------------------------------------------------------------ From 15014db8d58892488f6a270148279e053a472bfb Mon Sep 17 00:00:00 2001 From: Tanmay Patil <92677342+TanmayPatil105@users.noreply.github.com> Date: Sat, 5 Nov 2022 00:12:05 +0530 Subject: [PATCH 22/77] feat(web-search): add ask.com (#11292) --- plugins/web-search/README.md | 1 + plugins/web-search/web-search.plugin.zsh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index 54232a910..0bf9f26ad 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -43,6 +43,7 @@ Available search contexts are: | `wolframalpha` | `https://wolframalpha.com/input?i=` | | `archive` | `https://web.archive.org/web/*/` | | `scholar` | `https://scholar.google.com/scholar?q=` | +| `ask` | `https://www.ask.com/web?q=` | Also there are aliases for bang-searching DuckDuckGo: diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index d8b4a7f8b..ec176dd68 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -24,6 +24,7 @@ function web_search() { wolframalpha "https://www.wolframalpha.com/input/?i=" archive "https://web.archive.org/web/*/" scholar "https://scholar.google.com/scholar?q=" + ask "https://www.ask.com/web?q=" ) # check whether the search engine is supported @@ -64,6 +65,7 @@ alias stackoverflow='web_search stackoverflow' alias wolframalpha='web_search wolframalpha' alias archive='web_search archive' alias scholar='web_search scholar' +alias ask='web_search ask' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' From 80fdbc9b91a9acca42fb90065b5e64a9722978a7 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 4 Nov 2022 19:45:17 +0100 Subject: [PATCH 23/77] fix(git): remove unused escape chars Closes #11176 --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f25453bc1..5c0e6db2c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -302,7 +302,7 @@ alias gtv='git tag | sort -V' alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' -alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' +alias gunwip='git log -n 1 | grep -q -c "--wip--" && git reset HEAD~1' alias gup='git pull --rebase' alias gupv='git pull --rebase -v' alias gupa='git pull --rebase --autostash' From 3eda3e5650c72c5f71336fcc2c8dfa5b861acb6d Mon Sep 17 00:00:00 2001 From: Jeremy Combs Date: Sun, 6 Nov 2022 14:50:39 -0500 Subject: [PATCH 24/77] feat(encode64): add `encodefile64` function (#10813) Co-authored-by: Jeremy Combs --- plugins/encode64/README.md | 23 +++++++++++++++++++---- plugins/encode64/encode64.plugin.zsh | 10 ++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md index 86320cffb..7cdf8c3f3 100644 --- a/plugins/encode64/README.md +++ b/plugins/encode64/README.md @@ -10,10 +10,11 @@ plugins=(... encode64) ## Functions and Aliases -| Function | Alias | Description | -| ---------- | ----- | ------------------------------ | -| `encode64` | `e64` | Encodes given data to base64 | -| `decode64` | `d64` | Decodes given data from base64 | +| Function | Alias | Description | +| -------------- | ------ | -------------------------------------- | +| `encode64` | `e64` | Encodes given data to base64 | +| `encodefile64` | `ef64` | Encodes given file's content to base64 | +| `decode64` | `d64` | Decodes given data from base64 | ## Usage and examples @@ -37,6 +38,20 @@ plugins=(... encode64) b2gtbXktenNo== ``` +### Encoding a file + +Encode a file's contents to base64 and save output to text file. +**NOTE:** Takes provided file and saves encoded content as new file with `.txt` extension + +- From parameter + + ```console + $ encodefile64 ohmyzsh.icn + ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt + $ ef64 "oh-my-zsh" + ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt + ``` + ### Decoding - From parameter diff --git a/plugins/encode64/encode64.plugin.zsh b/plugins/encode64/encode64.plugin.zsh index 979e06742..6927f5216 100644 --- a/plugins/encode64/encode64.plugin.zsh +++ b/plugins/encode64/encode64.plugin.zsh @@ -6,6 +6,15 @@ encode64() { fi } +encodefile64() { + if [[ $# -eq 0 ]]; then + echo "You must provide a filename" + else + base64 -i $1 -o $1.txt + echo "${1}'s content encoded in base64 and saved as ${1}.txt" + fi +} + decode64() { if [[ $# -eq 0 ]]; then cat | base64 --decode @@ -14,4 +23,5 @@ decode64() { fi } alias e64=encode64 +alias ef64=encodefile64 alias d64=decode64 From 4806f755694d160f20e3fb8ae0a1d009d56d966b Mon Sep 17 00:00:00 2001 From: Atk Date: Sun, 6 Nov 2022 19:52:53 +0000 Subject: [PATCH 25/77] feat(wd): update to latest upstream release (#11235) Based on https://github.com/mfaerevaag/wd/releases/tag/v0.5.2 --- plugins/wd/README.md | 8 ++++++-- plugins/wd/wd.sh | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 8791f9f0e..1d1980632 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -1,12 +1,12 @@ # wd -[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) +[![Build Status](https://github.com/mfaerevaag/wd/actions/workflows/test.yml/badge.svg)](https://github.com/mfaerevaag/wd/actions) `wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path. -![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif) +![Demo](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif) ## Setup @@ -36,6 +36,10 @@ In your `.zshrc`: antibody bundle mfaerevaag/wd ``` +### [Fig](https://fig.io) + +Install `wd` here: [![Fig plugin store](https://fig.io/badges/install-with-fig.svg)](https://fig.io/plugins/other/wd_mfaerevaag) + ### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/)) 1. Install from the AUR diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index 9085c5b7b..e51cf906a 100644 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -163,6 +163,7 @@ wd_add() { local point=$1 local force=$2 + cmdnames=(add rm show list ls path clean help) if [[ $point == "" ]] then @@ -178,6 +179,9 @@ wd_add() elif [[ $point =~ : ]] || [[ $point =~ / ]] then wd_exit_fail "Warp point contains illegal character (:/)" + elif (($cmdnames[(Ie)$point])) + then + wd_exit_fail "Warp point name cannot be a wd command (see wd -h for a full list)" elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ] then wd_remove "$point" > /dev/null @@ -185,7 +189,7 @@ wd_add() if (whence sort >/dev/null); then local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") # use 'cat' below to ensure we respect $WD_CONFIG as a symlink - command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}" + command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" >| "$WD_CONFIG" && command rm "${config_tmp}" fi wd_export_static_named_directories @@ -214,7 +218,7 @@ wd_remove() then local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") # Copy and delete in two steps in order to preserve symlinks - if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp" + if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" >| "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp" then wd_print_msg "$WD_GREEN" "Warp point removed" else @@ -251,7 +255,7 @@ wd_list_all() then arr=(${(s,:,)line}) key=${arr[1]} - val=${arr[2]} + val=${line#"${arr[1]}:"} if [[ -z $wd_quiet_mode ]] then @@ -389,6 +393,11 @@ else wd_export_static_named_directories fi +# disable extendedglob for the complete wd execution time +setopt | grep -q extendedglob +wd_extglob_is_set=$? +[[ $wd_extglob_is_set ]] && setopt noextendedglob + # load warp points typeset -A points while read -r line @@ -475,6 +484,9 @@ fi # if not, next time warp will pick up variables from this run # remember, there's no sub shell +[[ $wd_extglob_is_set ]] && setopt extendedglob + +unset wd_extglob_is_set unset wd_warp unset wd_add unset wd_remove From 4e2317c757674af8264bbcc4edd79b2d42f6d781 Mon Sep 17 00:00:00 2001 From: Julian <62412964+julianadler@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:46:48 +1300 Subject: [PATCH 26/77] fix(lol): use https for `yolo` calls (#11320) --- plugins/lol/README.md | 4 ++-- plugins/lol/lol.plugin.zsh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/lol/README.md b/plugins/lol/README.md index ea6b0c3b8..b45513b35 100644 --- a/plugins/lol/README.md +++ b/plugins/lol/README.md @@ -49,7 +49,7 @@ plugins=(... lol) | `violenz` | `git rebase` | | `visible` | `echo` | | `wtf` | `dmesg` | -| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` | +| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` | ## Usage Examples @@ -66,6 +66,6 @@ nowai u=r,go= some.file # ssh root@catserver.org pwned root@catserver.org -# git commit -m "$(curl -s http://whatthecommit.com/index.txt)" +# git commit -m "$(curl -s https://whatthecommit.com/index.txt)" yolo ``` diff --git a/plugins/lol/lol.plugin.zsh b/plugins/lol/lol.plugin.zsh index 3c30259a1..585f96e4f 100644 --- a/plugins/lol/lol.plugin.zsh +++ b/plugins/lol/lol.plugin.zsh @@ -45,7 +45,7 @@ alias bringz='git pull' alias chicken='git add' alias oanward='git commit -m' alias ooanward='git commit -am' -alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"' +alias yolo='git commit -m "$(curl -s https://whatthecommit.com/index.txt)"' alias letcat='git checkout' alias violenz='git rebase' From ac0924930d48217e127523809dc5d386fb3403a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng?= <10150902+hoang-himself@users.noreply.github.com> Date: Mon, 7 Nov 2022 15:47:59 +0700 Subject: [PATCH 27/77] feat(git): add aliases for `worktree` (#10079) --- plugins/git/README.md | 11 ++++++++--- plugins/git/git.plugin.zsh | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 050c13d81..f1c8b81c4 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -91,8 +91,8 @@ plugins=(... git) | gignore | git update-index --assume-unchanged | | gignored | git ls-files -v \| grep "^[[:lower:]]" | | git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | -| gk | gitk --all --branches &! | -| gke | gitk --all $(git log -g --pretty=%h) &! | +| gk | gitk --all --branches &! | +| gke | gitk --all $(git log -g --pretty=%h) &! | | gl | git pull | | glg | git log --stat | | glgp | git log --stat -p | @@ -184,7 +184,7 @@ plugins=(... git) | gupom | git pull --rebase origin $(git_main_branch) | | gupomi | git pull --rebase=interactive origin $(git_main_branch) | | glum | git pull upstream $(git_main_branch) | -| gluc | git pull upstream $(git_current_branch) | +| gluc | git pull upstream $(git_current_branch) | | gwch | git whatchanged -p --abbrev-commit --pretty=medium | | gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | | gam | git am | @@ -192,6 +192,11 @@ plugins=(... git) | gams | git am --skip | | gama | git am --abort | | gamscp | git am --show-current-patch | +| gwt | git worktree | +| gwta | git worktree add | +| gwtls | git worktree list | +| gwtmv | git worktree move | +| gwtrm | git worktree remove | ### Main branch preference diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 5c0e6db2c..fc7699237 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -315,6 +315,12 @@ alias gluc='git pull upstream $(git_current_branch)' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' +alias gwt='git worktree' +alias gwta='git worktree add' +alias gwtls='git worktree list' +alias gwtmv='git worktree move' +alias gwtrm='git worktree remove' + alias gam='git am' alias gamc='git am --continue' alias gams='git am --skip' From 0145d744a9c4c11f00992f7f3ad9555bc8ac6177 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 7 Nov 2022 12:59:12 +0100 Subject: [PATCH 28/77] fix(git): escape first hyphen in `gunwip` --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index fc7699237..26f4beeb3 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -302,7 +302,7 @@ alias gtv='git tag | sort -V' alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' -alias gunwip='git log -n 1 | grep -q -c "--wip--" && git reset HEAD~1' +alias gunwip='git log -n 1 | grep -q -c "\--wip--" && git reset HEAD~1' alias gup='git pull --rebase' alias gupv='git pull --rebase -v' alias gupa='git pull --rebase --autostash' From 6df14641ac48b380c56e1c72aa86b57861fbfb70 Mon Sep 17 00:00:00 2001 From: Gheritarish Date: Mon, 7 Nov 2022 19:53:36 +0100 Subject: [PATCH 29/77] feat(1password): add username copy to `opswd` (#10812) --- plugins/1password/README.md | 16 +++++++++------- plugins/1password/opswd | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/plugins/1password/README.md b/plugins/1password/README.md index f6854da53..ace6da8e1 100644 --- a/plugins/1password/README.md +++ b/plugins/1password/README.md @@ -14,16 +14,18 @@ clipboard. ## `opswd` The `opswd` command is a wrapper around the `op` command. It takes a service -name as an argument and copies the password for that service to the clipboard. +name as an argument and copies the username, then the password for that service +to the clipboard, after confirmation on the user part. -If the service also contains a TOTP, it is copied to the clipboard after 10 seconds. -Finally, after 20 seconds, the clipboard is cleared. +If the service also contains a TOTP, it is copied to the clipboard after confirmation +on the user part. Finally, after 20 seconds, the clipboard is cleared. -The function has completion support, so you can use tab completion to select -which service you want to get. +For example, `opswd github.com` will put your GitHub username into your clipboard. Then, +it will ask for confirmation to continue, and copy the password to your clipboard. Finally, +if a TOTP is available, it will be copied to the clipboard after your confirmation. -For example, `opswd github.com` will put your GitHub password into your clipboard, and if -a TOTP is available, it will be copied to the clipboard after 10 seconds. +This function has completion support, so you can use tab completion to select which +service you want to get. > NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock, > 1Password CLI will automatically prompt you to sign in. See: diff --git a/plugins/1password/opswd b/plugins/1password/opswd index 57672807e..0f667d2ff 100644 --- a/plugins/1password/opswd +++ b/plugins/1password/opswd @@ -14,6 +14,17 @@ function opswd() { # If not logged in, print error and return op user list > /dev/null || return + local username + # Copy the username to the clipboard + if ! username=$(op item get "$service" --fields username 2>/dev/null); then + echo "error: could not obtain username for $service" + return 1 + fi + + echo -n "$username" | clipcopy + echo "✔ username for service $service copied to the clipboard. Press Enter to continue" + read + local password # Copy the password to the clipboard if ! password=$(op item get "$service" --fields password 2>/dev/null); then @@ -22,12 +33,13 @@ function opswd() { fi echo -n "$password" | clipcopy - echo "✔ password for $service copied to clipboard" + echo "✔ password for $service copied to clipboard. Press Enter to continue" + read - # If there's a one time password, copy it to the clipboard after 10 seconds + # If there's a one time password, copy it to the clipboard local totp if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then - sleep 10 && echo -n "$totp" | clipcopy + echo -n "$totp" | clipcopy echo "✔ TOTP for $service copied to clipboard" fi From 6dfc9b960f023f30d6c55a22fa8402d91beb8d1f Mon Sep 17 00:00:00 2001 From: Banst Date: Tue, 8 Nov 2022 09:34:13 +0100 Subject: [PATCH 30/77] feat(git): display tag in git-prompt when possible (#11318) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- lib/git.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/git.zsh b/lib/git.zsh index be9fa7e67..f049f73c2 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -19,6 +19,7 @@ function git_prompt_info() { local ref ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \ + || ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \ || ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \ || return 0 From 1f30c1a079cd10030578e38f8562dc5be53d0fd3 Mon Sep 17 00:00:00 2001 From: Sandeep Tailor Date: Tue, 8 Nov 2022 13:45:42 +0000 Subject: [PATCH 31/77] feat(hasura): add completion plugin (#11278) --- plugins/hasura/README.md | 9 +++++++++ plugins/hasura/hasura.plugin.zsh | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 plugins/hasura/README.md create mode 100644 plugins/hasura/hasura.plugin.zsh diff --git a/plugins/hasura/README.md b/plugins/hasura/README.md new file mode 100644 index 000000000..d7db9ed92 --- /dev/null +++ b/plugins/hasura/README.md @@ -0,0 +1,9 @@ +# Hasura plugin + +This plugin adds completion for [the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/index/). + +To use it, add `hasura` to the plugins array in your zshrc file: + +```zsh +plugins=(... hasura) +``` diff --git a/plugins/hasura/hasura.plugin.zsh b/plugins/hasura/hasura.plugin.zsh new file mode 100644 index 000000000..18254c43b --- /dev/null +++ b/plugins/hasura/hasura.plugin.zsh @@ -0,0 +1,13 @@ +if (( ! $+commands[hasura] )); 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/_hasura" ]]; then + hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null + source "$ZSH_CACHE_DIR/completions/_hasura" +else + source "$ZSH_CACHE_DIR/completions/_hasura" + hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null &| +fi From 9f77cb29d7557ec6ce453a7372b053931a7d034d Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Fri, 15 Apr 2022 20:43:43 +0200 Subject: [PATCH 32/77] feat(sigstore): add completion plugin Closes #10862 Signed-off-by: Marco Franssen Co-authored-by: Carlo Sala --- plugins/sigstore/README.md | 13 +++++++++++++ plugins/sigstore/sigstore.plugin.zsh | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 plugins/sigstore/README.md create mode 100644 plugins/sigstore/sigstore.plugin.zsh diff --git a/plugins/sigstore/README.md b/plugins/sigstore/README.md new file mode 100644 index 000000000..00e83c8c2 --- /dev/null +++ b/plugins/sigstore/README.md @@ -0,0 +1,13 @@ +# Sigstore plugin + +This plugin sets up completion for the following [Sigstore](https://sigstore.dev/) CLI tools. + +- [Cosign](https://docs.sigstore.dev/cosign/overview) +- [Sget](https://docs.sigstore.dev/cosign/installation#alpine-linux) +- [Rekor](https://docs.sigstore.dev/rekor/overview) + +To use it, add `sigstore` to the plugins array in your zshrc file: + +```zsh +plugins=(... sigstore) +``` diff --git a/plugins/sigstore/sigstore.plugin.zsh b/plugins/sigstore/sigstore.plugin.zsh new file mode 100644 index 000000000..1f9d77c11 --- /dev/null +++ b/plugins/sigstore/sigstore.plugin.zsh @@ -0,0 +1,22 @@ +function install_autocompletion { + if (( ! $+commands[$1] )); then + return + fi + + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `$1` (cosign, sget, rekor-cli). Otherwise, compinit will + # have already done that + if [[ ! -f "$ZSH_CACHE_DIR/completions/_$1" ]]; then + autoload -Uz _$1 + typeset -g -A _comps + _comps[$1]=_$1 + fi + + $1 completion zsh >| "$ZSH_CACHE_DIR/completions/_$1" &| +} + +install_autocompletion cosign +install_autocompletion sget +install_autocompletion rekor-cli + +unfunction install_autocompletion From 23de5d95285a6b119d7c99f777051d9c5ec69ef8 Mon Sep 17 00:00:00 2001 From: cxy004 Date: Thu, 10 Nov 2022 06:04:55 +0800 Subject: [PATCH 33/77] fix(colorize): check if $ZSH_COLORIZE_TOOL exists (#11325) --- plugins/colorize/colorize.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index a9da6cf83..12841e0ee 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -23,7 +23,7 @@ colorize_check_requirements() { if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2 return 1 - elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then + elif ! (( $+commands[$ZSH_COLORIZE_TOOL] )); then echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2 return 1 fi From fcbfdf42de702d55174fe2b19142ba232289671e Mon Sep 17 00:00:00 2001 From: Marcos Alano Date: Thu, 10 Nov 2022 18:36:51 +0100 Subject: [PATCH 34/77] feat(terraform): load completion from bash Closes #11328 Closes #11330 --- plugins/terraform/_terraform | 411 ------------------------- plugins/terraform/terraform.plugin.zsh | 5 + 2 files changed, 5 insertions(+), 411 deletions(-) delete mode 100644 plugins/terraform/_terraform diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform deleted file mode 100644 index 625834563..000000000 --- a/plugins/terraform/_terraform +++ /dev/null @@ -1,411 +0,0 @@ -#compdef terraform - -local -a _terraform_cmds opt_args -_terraform_cmds=( - 'apply:Builds or changes infrastructure' - 'console:Interactive console for Terraform interpolations' - 'destroy:Destroy Terraform-managed infrastructure' - 'fmt:Rewrites config files to canonical format' - 'force-unlock:Manually unlock the terraform state' - 'get:Download and install modules for the configuration' - 'graph:Create a visual graph of Terraform resources' - 'import:Import existing infrastructure into Terraform' - 'init:Initialize a Terraform working directory' - 'login:Obtain and save credentials for a remote host' - 'logout:Remove locally-stored credentials for a remote host' - 'output:Read an output from a state file' - 'plan:Generate and show an execution plan' - 'providers:Prints a tree of the providers used in the configuration' - 'refresh:Update local state file against real resources' - 'show:Inspect Terraform state or plan' - 'state:Advanced state management' - 'taint:Manually mark a resource for recreation' - 'untaint:Manually unmark a resource as tainted' - 'validate:Validates the Terraform files' - 'version:Prints the Terraform version' - 'workspace:Workspace management' - '0.12upgrade:Rewrites pre-0.12 module source code for v0.12' - '0.13upgrade:Rewrites pre-0.13 module source code for v0.13' -) - -__012upgrade() { - _arguments \ - '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \ - '-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]' -} - -__013upgrade() { - _arguments \ - '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' -} - -__apply() { - _arguments \ - '-auto-approve[Skip interactive approval of plan before applying.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-no-color[If specified, output will be colorless.]' \ - '-parallelism=[(10) Limit the number of parallel resource operations.]' \ - '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__console() { - _arguments \ - '-state=[(terraform.tfstate) Path to read state.]' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__destroy() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-auto-approve[Skip interactive approval before destroying.]' \ - '-force[Deprecated: same as auto-approve.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-parallelism=[(10) Limit the number of concurrent operations.]' \ - '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__fmt() { - _arguments \ - '-list=[(true) List files whose formatting differs (always false if using STDIN)]' \ - '-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \ - '-diff=[(false) Display diffs of formatting changes]' \ - '-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \ - '-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]' -} - -__force_unlock() { - _arguments \ - "-force[Don't ask for input for unlock confirmation.]" -} - -__get() { - _arguments \ - '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \ - '-no-color[Disable text coloring in the output.]' -} - -__graph() { - _arguments \ - '-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \ - '-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]' -} - -__import() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \ - '-allow-missing-config[Allow import when no resource configuration block exists.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__init() { - _arguments \ - '-backend=[(true) Configure the backend for this configuration.]' \ - '-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \ - '-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \ - '-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \ - '-get=[(true) Download any modules for this configuration.]' \ - '-get-plugins=[(true) Download any missing plugins for this configuration.]' \ - '-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \ - '-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \ - '-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \ - '-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]' -} - -__login() { - _arguments \ - -} - -__logout() { - _arguments \ - -} - -__output() { - _arguments \ - '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-no-color[If specified, output will contain no color.]' \ - '-json[If specified, machine readable output will be printed in JSON format]' -} - -__plan() { - _arguments \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \ - '-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[() If specified, output will contain no color.]' \ - '-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \ - '-parallelism=[(10) Limit the number of concurrent operations.]' \ - '-refresh=[(true) Update state prior to checking for differences.]' \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__providers() { - local -a __providers_cmds - __providers_cmds=( - 'mirror:Mirrors the provider plugins needed for the current configuration' - 'schema:Prints the schemas of the providers used in the configuration' - ) - _describe -t providers "providers commands" __providers_cmds - -} - -__providers_mirror() { - _arguments \ - '-platform=[(os_arch) Choose which target platform to build a mirror for.]' \ - "*:target_dir:_files -/" -} - -__providers_schema() { - _arguments \ - '-json[]' \ - '::' -} - -__refresh() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will not contain any color.]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__show() { - _arguments \ - '-json[If specified, output the Terraform plan or state in a machine-readable form.]' \ - '-no-color[If specified, output will not contain any color.]' -} - -__state() { - local -a __state_cmds - __state_cmds=( - 'list:List resources in the state' - 'mv:Move an item in the state' - 'pull:Pull current state and output to stdout' - 'push:Update remote state from a local state file' - 'replace-provider:Replace provider for resources in the Terraform state' - 'rm:Remove instances from the state' - 'show:Show a resource in the state' - ) - _describe -t state "state commands" __state_cmds -} - -__state_list() { - _arguments \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \ - '-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \ - "*:address:__statelist" -} - -__state_mv() { - _arguments \ - "-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \ - '-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \ - '-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \ - "::" \ - ":source:__statelist" \ - ":destination: " -} - -__state_push() { - _arguments \ - "-force[Write the state even if lineages don't match or the remote serial is higher.]" \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - "::" \ - ":destination:_files" -} - -__state_replace_provider() { - _arguments \ - '-auto-approve[Skip interactive approval.]' \ - '-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - ":from_provider_fqn:" \ - ":to_provider_fqn:" -} - -__state_rm() { - _arguments \ - "-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \ - '-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - - -__state_show() { - _arguments \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - -__statelist() { - compadd $(terraform state list $opt_args[-state]) -} - -__taint() { - _arguments \ - '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - -__untaint() { - _arguments \ - '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' -} - -__validate() { - _arguments \ - '-no-color[If specified, output will not contain any color.]' \ - '-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \ - ':dir:_files -/' -} - -__version() { - _arguments \ - '-json[Output the version information as a JSON object.]' -} - -__workspace() { - local -a __workspace_cmds - __workspace_cmds=( - 'delete:Delete a workspace' - 'list:List Workspaces' - 'new:Create a new workspace' - 'select:Select a workspace' - 'show:Show the name of the current workspace' - ) - _describe -t workspace "workspace commands" __workspace_cmds -} - -_arguments '*:: :->command' - -if (( CURRENT == 1 )); then - _describe -t commands "terraform command" _terraform_cmds - return -fi - -local -a _command_args -case "$words[1]" in - 0.12upgrade) - __012upgrade ;; - 0.13upgrade) - __013upgrade ;; - apply) - __apply ;; - console) - __console;; - destroy) - __destroy ;; - fmt) - __fmt;; - force-unlock) - __force_unlock;; - get) - __get ;; - graph) - __graph ;; - import) - __import;; - init) - __init ;; - login) - __login ;; - logout) - __logout ;; - output) - __output ;; - plan) - __plan ;; - providers) - test $CURRENT -lt 3 && __providers - [[ $words[2] = "mirror" ]] && __providers_mirror - [[ $words[2] = "schema" ]] && __providers_schema - ;; - refresh) - __refresh ;; - show) - __show ;; - state) - test $CURRENT -lt 3 && __state - [[ $words[2] = "list" ]] && __state_list - [[ $words[2] = "mv" ]] && __state_mv - [[ $words[2] = "push" ]] && __state_push - [[ $words[2] = "replace-provider" ]] && __state_replace_provider - [[ $words[2] = "rm" ]] && __state_rm - [[ $words[2] = "show" ]] && __state_show - ;; - taint) - __taint ;; - untaint) - __untaint ;; - validate) - __validate ;; - version) - __version ;; - workspace) - test $CURRENT -lt 3 && __workspace ;; -esac diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index d9e39e6ac..eaa1e2e81 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -16,3 +16,8 @@ alias tfi='terraform init' alias tfo='terraform output' alias tfp='terraform plan' alias tfv='terraform validate' + +if (( $+commands[terraform] )); then + autoload -U +X bashcompinit && bashcompinit + complete -o nospace -C terraform terraform +fi From 5bfdd0356b46dc711a8f0866eeb9b717c033d5b2 Mon Sep 17 00:00:00 2001 From: Haltarys <45515869+Haltarys@users.noreply.github.com> Date: Fri, 11 Nov 2022 09:49:41 +0100 Subject: [PATCH 35/77] fix(ubuntu)!: rename `acs` alias to `acse (#11334) BREAKING CHANGE: `acs` alias, present in both `ubuntu` and `debian` plugins conflicts with `acs` function in aliases plugin. Change it to prevent ghosting of one of them. --- plugins/debian/README.md | 2 +- plugins/debian/debian.plugin.zsh | 4 ++-- plugins/ubuntu/README.md | 2 +- plugins/ubuntu/ubuntu.plugin.zsh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/debian/README.md b/plugins/debian/README.md index 1db534f13..c1ebe1c50 100644 --- a/plugins/debian/README.md +++ b/plugins/debian/README.md @@ -21,7 +21,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh | ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- | | `age` | `apt-get` | Command line tool for handling packages | | `api` | `aptitude` | Same functionality as `apt-get`, provides extra options | -| `acs` | `apt-cache search` | Command line tool for searching apt software package cache | +| `acse` | `apt-cache search` | Command line tool for searching apt software package cache | | `aps` | `aptitude search` | Searches installed packages using aptitude | | `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format | | `afs` | `apt-file search --regexp` | Search file in packages | diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 2d8c4666e..bab1ae1c6 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -26,7 +26,7 @@ alias age='apt-get' alias api='aptitude' # Some self-explanatory aliases -alias acs="apt-cache search" +alias acse="apt-cache search" alias aps='aptitude search' alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search" @@ -51,7 +51,7 @@ if [[ $use_sudo -eq 1 ]]; then alias au="sudo $apt_pref $apt_upgr" alias ai="sudo $apt_pref install" # Install all packages given on the command line while using only the first word of each line: - # acs ... | ail + # acse ... | ail alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" alias ap="sudo $apt_pref purge" diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md index 20f5c65ee..2401c102b 100644 --- a/plugins/ubuntu/README.md +++ b/plugins/ubuntu/README.md @@ -15,7 +15,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other | Alias | Command | Description | |---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | age | `sudo $APT` | Run apt-get with sudo | -| acs | `apt-cache search` | Search the apt-cache with the specified criteria | +| acse | `apt-cache search` | Search the apt-cache with the specified criteria | | acsp | `apt-cache showpkg` | Shows information about the listed packages | | acp | `apt-cache policy` | Display the package source priorities | | afs | `apt-file search --regexp` | Perform a regular expression apt-file search | diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 7b765a406..4d35da2ac 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -1,6 +1,6 @@ (( $+commands[apt] )) && APT=apt || APT=apt-get -alias acs='apt-cache search' +alias acse='apt-cache search' alias afs='apt-file search --regexp' From 5b2d0a3f06a743cf9d33783276f29ea683db81c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 14 Oct 2022 18:07:18 +0200 Subject: [PATCH 36/77] perf(bgnotify): cache terminal app ID computation Fixes #10971 --- plugins/bgnotify/bgnotify.plugin.zsh | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 479796dbe..9c4a62cd7 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -20,25 +20,25 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi } fi -currentAppId () { - if (( $+commands[osascript] )); then - osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null +} + +function currentAppId { + if (( ${+commands[osascript]} )); then + # output: com.googlecode.iterm2, 116 + osascript -e 'tell application (path to frontmost application as text) to get the {id, id of front window}' 2>/dev/null + elif (( ${+commands[notify-send]} || ${+commands[kdialog]} )); then + xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0" + else + echo $EPOCHSECONDS fi } -currentWindowId () { - if hash osascript 2>/dev/null; then #osx - osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" - elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu! - xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0" - else - echo $EPOCHSECONDS #fallback for windows - fi -} +# currentAppId is expensive (more on macOS!) and it will remain the same until the shell is close +bgnotify_termid=$(currentAppId) bgnotify () { ## args: (title, subtitle) if hash terminal-notifier 2>/dev/null; then #osx - local term_id="$bgnotify_appid" + local term_id="${bgnotify_termid%%,*}" # remove window id if [[ -z "$term_id" ]]; then case "$TERM_PROGRAM" in iTerm.app) term_id='com.googlecode.iterm2' ;; @@ -69,8 +69,6 @@ bgnotify () { ## args: (title, subtitle) bgnotify_begin() { bgnotify_timestamp=$EPOCHSECONDS bgnotify_lastcmd="${1:-$2}" - bgnotify_appid="$(currentAppId)" - bgnotify_windowid=$(currentWindowId) } bgnotify_end() { @@ -78,7 +76,7 @@ bgnotify_end() { elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) past_threshold=$(( elapsed >= bgnotify_threshold )) if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then - if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then + if [[ $(currentAppId) != "$bgnotify_termid" ]]; then print -n "\a" bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" fi From a04cf078801db637c2ecdcc95c491fa9fb217ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 14 Oct 2022 18:36:48 +0200 Subject: [PATCH 37/77] refactor(bgnotify): clean up and reorganize code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🗸 Standardize code style 🗸 Organize code sections 🗸 Optimize calls for window ID --- plugins/bgnotify/bgnotify.plugin.zsh | 125 +++++++++++++++------------ 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 9c4a62cd7..ed2653aa8 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -1,43 +1,78 @@ #!/usr/bin/env zsh -## setup ## +## Setup -[[ -o interactive ]] || return #interactive only! -zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date() -autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } +[[ -o interactive ]] || return # don't load on non-interactive shells +[[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]] || return # don't load on a SSH connection -(( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds +zmodload zsh/datetime # faster than `date` -## definitions ## - -if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override - function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds) - elapsed="$(( $3 % 60 ))s" - (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed" - (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed" - [ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2" - } -fi +## Zsh Hooks +function bgnotify_begin { + bgnotify_timestamp=$EPOCHSECONDS + bgnotify_lastcmd="${1:-$2}" } -function currentAppId { +function bgnotify_end { + { + local exit_status=$? + local elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) + + # check time elapsed + [[ $bgnotify_timestamp -gt 0 ]] || return + [[ $elapsed -ge $bgnotify_threshold ]] || return + + # check if Terminal app is not active + [[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return + + printf '\a' # beep sound + bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed" + } always { + bgnotify_timestamp=0 + } +} + +autoload -Uz add-zsh-hook +add-zsh-hook preexec bgnotify_begin +add-zsh-hook precmd bgnotify_end + + +## Functions + +# allow custom function override +(( ${+functions[bgnotify_formatted]} )) || \ +function bgnotify_formatted { + local exit_status=$1 + local cmd="$2" + + # humanly readable elapsed time + local elapsed="$(( $3 % 60 ))s" + (( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed" + (( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed" + + if [[ $1 -eq 0 ]]; then + bgnotify "#win (took $elapsed)" "$2" + else + bgnotify "#fail (took $elapsed)" "$2" + fi +} + +# for macOS, output is "app ID, window ID" (com.googlecode.iterm2, 116) +function bgnotify_appid { if (( ${+commands[osascript]} )); then - # output: com.googlecode.iterm2, 116 osascript -e 'tell application (path to frontmost application as text) to get the {id, id of front window}' 2>/dev/null - elif (( ${+commands[notify-send]} || ${+commands[kdialog]} )); then - xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0" + elif (( ${+commands[xprop]} )); then + xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5 else echo $EPOCHSECONDS fi } -# currentAppId is expensive (more on macOS!) and it will remain the same until the shell is close -bgnotify_termid=$(currentAppId) - -bgnotify () { ## args: (title, subtitle) - if hash terminal-notifier 2>/dev/null; then #osx +function bgnotify { + # $1: title, $2: message + if (( ${+commands[terminal-notifier]} )); then # macOS local term_id="${bgnotify_termid%%,*}" # remove window id if [[ -z "$term_id" ]]; then case "$TERM_PROGRAM" in @@ -46,46 +81,26 @@ bgnotify () { ## args: (title, subtitle) esac fi - ## now call terminal-notifier, (hopefully with $term_id!) if [[ -z "$term_id" ]]; then - terminal-notifier -message "$2" -title "$1" >/dev/null + terminal-notifier -message "$2" -title "$1" &>/dev/null else - terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null + terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" &>/dev/null fi - elif hash growlnotify 2>/dev/null; then #osx growl + elif (( ${+commands[growlnotify]} )); then # macOS growl growlnotify -m "$1" "$2" - elif hash notify-send 2>/dev/null; then #ubuntu gnome! + elif (( ${+commands[notify-send]} )); then # GNOME notify-send "$1" "$2" - elif hash kdialog 2>/dev/null; then #ubuntu kde! + elif (( ${+commands[kdialog]} )); then # KDE kdialog --title "$1" --passivepopup "$2" 5 - elif hash notifu 2>/dev/null; then #cygwyn support! + elif (( ${+commands[notifu]} )); then # cygwin notifu /m "$2" /p "$1" fi } +## Defaults -## Zsh hooks ## +# notify if command took longer than 5s by default +bgnotify_threshold=${bgnotify_threshold:-5} -bgnotify_begin() { - bgnotify_timestamp=$EPOCHSECONDS - bgnotify_lastcmd="${1:-$2}" -} - -bgnotify_end() { - didexit=$? - elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) - past_threshold=$(( elapsed >= bgnotify_threshold )) - if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then - if [[ $(currentAppId) != "$bgnotify_termid" ]]; then - print -n "\a" - bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" - fi - fi - bgnotify_timestamp=0 #reset it to 0! -} - -## only enable if a local (non-ssh) connection -if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then - add-zsh-hook preexec bgnotify_begin - add-zsh-hook precmd bgnotify_end -fi +# bgnotify_appid is slow in macOS and the terminal ID won't change, so cache it at startup +bgnotify_termid="$(bgnotify_appid)" From 62929263fafd9e3c1da043bc9b40fa97fccfa7a1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 11 Feb 2022 15:20:03 +0100 Subject: [PATCH 38/77] fix(perms)!: change function name from `fixperms` to `resetperms` and document caution (#10686) BREAKING CHANGE: function `fixperms` has been renamed to the more accurate `resetperms`. Please read the README carefully before using it as it may badly reset the permissions. Fixes #10648 Closes #10686 --- plugins/perms/README.md | 16 +++++++++++++--- plugins/perms/perms.plugin.zsh | 27 ++++++++++++++++----------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/plugins/perms/README.md b/plugins/perms/README.md index ae7a36b9d..ae10fa659 100644 --- a/plugins/perms/README.md +++ b/plugins/perms/README.md @@ -10,6 +10,16 @@ plugins=(... perms) ## Usage -* `set755` recursively sets all given directories (default to .) to octal 755. -* `set644` recursively sets all given files (default to .) to octal 644. -* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases. +> **CAUTION:** these functions are harmful if you don't know what they do. + +- `set755`: sets the permission to octal 755 for all given directories and their child directories (by default, starting from the current directory). + +- `set644`: sets the permission to octal 644 for all files of the given directory (by default, the current directory), recursively. It will only affect regular files (no symlinks). + +- `resetperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. + It will set the permissions to 755 for directories, and 644 for files. + +## Reference + +- octal 644: _read and write_ for the owner, _read_ for the group and others users. +- octal 755: _read, write and execute_ permissions for the owner, and _read and execute_ for the group and others users. diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 1a7472c1c..353b58411 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,25 +6,25 @@ ### Aliases # Set all files' permissions to 644 recursively in a directory -set644() { +function set644 { find "${@:-.}" -type f ! -perm 644 -print0 | xargs -0 chmod 644 } # Set all directories' permissions to 755 recursively in a directory -set755() { +function set755 { find "${@:-.}" -type d ! -perm 755 -print0 | xargs -0 chmod 755 } ### Functions -# fixperms - fix permissions on files and directories, with confirmation +# resetperms - fix permissions on files and directories, with confirmation # Returns 0 on success, nonzero if any errors occurred -fixperms () { +function resetperms { local opts confirm target exit_status chmod_opts use_slow_mode zparseopts -E -D -a opts -help -slow v+=chmod_opts if [[ $# > 1 || -n "${opts[(r)--help]}" ]]; then cat < Date: Sat, 12 Nov 2022 11:46:06 +0100 Subject: [PATCH 39/77] feat(git-prompt): show deleted files (#11245) --- plugins/git-prompt/git-prompt.plugin.zsh | 5 +++++ plugins/git-prompt/gitstatus.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 0485e317c..dcda418cf 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -47,6 +47,7 @@ function update_current_git_vars() { GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] GIT_STASHED=$__CURRENT_GIT_STATUS[8] GIT_CLEAN=$__CURRENT_GIT_STATUS[9] + GIT_DELETED=$__CURRENT_GIT_STATUS[10] } git_super_status() { @@ -69,6 +70,9 @@ git_super_status() { if [ "$GIT_CHANGED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" fi + if [ "$GIT_DELETED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DELETED$GIT_DELETED%{${reset_color}%}" + fi if [ "$GIT_UNTRACKED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}" fi @@ -91,6 +95,7 @@ ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}" ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}" ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}" ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[blue]%}%{-%G%}" ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}" diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index b5c3c9a0c..94774d828 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -44,7 +44,7 @@ if po.returncode != 0: sys.exit(0) # Not a git repository # collect git status information -untracked, staged, changed, conflicts = [], [], [], [] +untracked, staged, changed, deleted, conflicts = [], [], [], [], [] ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: @@ -75,13 +75,15 @@ for st in status: else: if st[1] == 'M': changed.append(st) + if st[1] == 'D': + deleted.append(st) if st[0] == 'U': conflicts.append(st) elif st[0] != ' ': staged.append(st) stashed = get_stash() -if not changed and not staged and not conflicts and not untracked: +if not changed and not deleted and not staged and not conflicts and not untracked: clean = 1 else: clean = 0 @@ -95,6 +97,7 @@ out = ' '.join([ str(len(changed)), str(len(untracked)), str(stashed), - str(clean) + str(clean), + str(len(deleted)) ]) print(out, end='') From b70977b25657c193a3a6c0445b63325a420da646 Mon Sep 17 00:00:00 2001 From: Isaac Levy Date: Mon, 14 Nov 2022 11:36:19 -0500 Subject: [PATCH 40/77] perf(pyenv): do not check if it's disabled (#11338) --- plugins/pyenv/pyenv.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 7fbd1589e..48c8ffaf5 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then eval "$(pyenv init - --no-rehash zsh)" # If pyenv-virtualenv exists, load it - if [[ "$(pyenv commands)" =~ "virtualenv-init" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then + if [[ "$ZSH_PYENV_VIRTUALENV" != false && "$(pyenv commands)" =~ "virtualenv-init" ]]; then eval "$(pyenv virtualenv-init - zsh)" fi From a482a02915f361e56669ee9884ebee0eb6f2d8d5 Mon Sep 17 00:00:00 2001 From: Lennart Ochel Date: Mon, 14 Nov 2022 17:38:44 +0100 Subject: [PATCH 41/77] feat(git-prompt): add option to show upstream branch (#11336) --- plugins/git-prompt/README.md | 2 ++ plugins/git-prompt/git-prompt.plugin.zsh | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md index 8775af893..05208d72f 100644 --- a/plugins/git-prompt/README.md +++ b/plugins/git-prompt/README.md @@ -45,6 +45,7 @@ The symbols are as follows: | ●n | there are `n` staged files | | ✖n | there are `n` unmerged files | | ✚n | there are `n` unstaged files | +| -n | there are `n` deleted files | | ⚑n | there are `n` stashed changes | | … | there are some untracked files | @@ -59,6 +60,7 @@ The symbols are as follows: ## Customisation - Set the variable `ZSH_THEME_GIT_PROMPT_CACHE` to any value in order to enable caching. +- Set the variable `ZSH_THEME_GIT_SHOW_UPSTREAM` to any value to display the upstream branch. - You may also change a number of variables (whose name start with `ZSH_THEME_GIT_PROMPT_`) to change the appearance of the prompt. Take a look at the bottom of the [plugin file](git-prompt.plugin.zsh)` to see what variables are available. diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index dcda418cf..487332028 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -48,12 +48,18 @@ function update_current_git_vars() { GIT_STASHED=$__CURRENT_GIT_STATUS[8] GIT_CLEAN=$__CURRENT_GIT_STATUS[9] GIT_DELETED=$__CURRENT_GIT_STATUS[10] + + if [ -z ${ZSH_THEME_GIT_SHOW_UPSTREAM+x} ]; then + GIT_UPSTREAM= + else + GIT_UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) && GIT_UPSTREAM="${ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR}${GIT_UPSTREAM}" + fi } git_super_status() { precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH$GIT_UPSTREAM%{${reset_color}%}" if [ "$GIT_BEHIND" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" fi @@ -101,6 +107,7 @@ ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}" ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{⚑%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" +ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR="->" # Set the prompt. RPROMPT='$(git_super_status)' From 37d9e1aee9289025373d3f840ead74897206d73f Mon Sep 17 00:00:00 2001 From: milinches Date: Sat, 7 May 2022 06:12:22 +0100 Subject: [PATCH 42/77] feat(golang): add `goe`, `gove` aliases Closes #10914 --- plugins/golang/README.md | 4 +++- plugins/golang/golang.plugin.zsh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/golang/README.md b/plugins/golang/README.md index 3b7d1e19f..128cc7fbb 100644 --- a/plugins/golang/README.md +++ b/plugins/golang/README.md @@ -16,11 +16,12 @@ plugins=(... golang) | gob | `go build` | Build your code | | goc | `go clean` | Removes object files from package source directories | | god | `go doc` | Prints documentation comments | +| goe | `go env` | Prints Go environment information | | gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. | | gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively | | gofx | `go fix` | Update packages to use a new API | | gog | `go get` | Downloads packages and then installs them to $GOPATH | -| gog | `go get ./...` | Installs all dependencies in current directory, recursively | +| goga | `go get ./...` | Installs all dependencies in current directory, recursively | | goi | `go install` | Compiles and installs packages to $GOPATH | | gol | `go list` | Lists Go packages | | gom | `go mod` | Access to operations on modules | @@ -35,4 +36,5 @@ plugins=(... golang) | gotod | `go tool dist` | Utility to bootstrap, build and test go runtime | | gotofx | `go tool fix` | Fixes an application to use newer features | | gov | `go vet` | Vet examines Go source code and reports suspicious constructs | +| gove | `go version` | Prints Go version | | gow | `go work` | Work provides access to operations on workspaces | diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 0dbaab069..45ccd3a1c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -13,6 +13,7 @@ unset p alias gob='go build' alias goc='go clean' alias god='go doc' +alias goe='go env' alias gof='go fmt' alias gofa='go fmt ./...' alias gofx='go fix' @@ -32,4 +33,5 @@ alias gotoc='go tool compile' alias gotod='go tool dist' alias gotofx='go tool fix' alias gov='go vet' +alias gove='go version' alias gow='go work' From aafc7443f07b841b4c008951087bfad282f3341f Mon Sep 17 00:00:00 2001 From: Steven Conaway Date: Tue, 15 Nov 2022 10:19:37 -0800 Subject: [PATCH 43/77] feat(fzf): support macOS ARM brew install dir (#10944) --- plugins/fzf/fzf.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 60ae0c765..9c8dd8648 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -9,6 +9,7 @@ function fzf_setup_using_base_dir() { "${HOME}/.nix-profile/share/fzf" "${XDG_DATA_HOME:-$HOME/.local/share}/fzf" "/usr/local/opt/fzf" + "/opt/homebrew/bin/fzf" "/usr/share/fzf" "/usr/local/share/examples/fzf" ) From 94584e2a7337e0a7f5af45e2c97ca6d0770e67a1 Mon Sep 17 00:00:00 2001 From: Bill Haofei Gong Date: Wed, 16 Nov 2022 05:25:22 +1100 Subject: [PATCH 44/77] feat(cakephp3): add compatibility with CakePHP 3.7+ (#11080) --- plugins/cakephp3/cakephp3.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/cakephp3/cakephp3.plugin.zsh b/plugins/cakephp3/cakephp3.plugin.zsh index dbfbeba3b..a1a289fd0 100644 --- a/plugins/cakephp3/cakephp3.plugin.zsh +++ b/plugins/cakephp3/cakephp3.plugin.zsh @@ -1,10 +1,10 @@ # CakePHP 3 basic command completion _cakephp3_get_command_list () { - bin/cake Completion commands + bin/cake completion commands } _cakephp3_get_sub_command_list () { - bin/cake Completion subcommands ${words[2]} + bin/cake completion subcommands ${words[2]} } _cakephp3_get_3rd_argument () { @@ -34,5 +34,5 @@ compdef _cakephp3 cake #Alias alias c3='bin/cake' -alias c3cache='bin/cake orm_cache clear' +alias c3cache='bin/cake schema_cache clear' alias c3migrate='bin/cake migrations migrate' From 4392d3a923eddd4e9d0f9b17a1e995cc9aa5cc96 Mon Sep 17 00:00:00 2001 From: Ben Iofel Date: Tue, 15 Nov 2022 18:29:48 +0000 Subject: [PATCH 45/77] feat(systemadmin): color `ip` if shell is interactive (#11107) --- plugins/systemadmin/systemadmin.plugin.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 8e5e0af71..9b5159ff1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -33,6 +33,14 @@ alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head # top10 of the history alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' +function ip() { + if [ -t 1 ]; then + command ip -color "$@" + else + command ip "$@" + fi +} + # directory LS function dls() { print -l *(/) From 6d5ba2d6c489d56fb34788ec128f98609e60b7be Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Nov 2022 20:23:09 +0100 Subject: [PATCH 46/77] feat(nvm)!: settings now are zstyle-based (#11335) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/nvm/README.md | 40 +++++++++++++++++++++++--------- plugins/nvm/nvm.plugin.zsh | 47 ++++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index 1acf12050..4c6312e6e 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -1,7 +1,7 @@ # nvm plugin -This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager. -It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`. +This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager. It also +automatically sources nvm, so you don't need to do it manually in your `.zshrc`. To use it, add `nvm` to the plugins array of your zshrc file: @@ -21,14 +21,32 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: [Homebrew is installed in `/opt/homebrew`](https://docs.brew.sh/Installation). To get the directory where nvm has been installed, regardless of chip architecture, use `NVM_HOMEBREW=$(brew --prefix nvm)`. -- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session, - set `NVM_LAZY` to `1`. This will source nvm script only when using it, and will create a function for `node`, - `npm`, `pnpm`, `yarn`, and the command(s) specified by `NVM_LAZY_CMD`, so when you call either of them, - nvm will be loaded and run with default version. +## Customization -- **`NVM_LAZY_CMD`**: if you want additional command(s) to trigger lazy loading of nvm, set `NVM_LAZY_CMD` to - the command or an array of the commands. +#### Lazy startup -- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when - if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating - which node version to load. +This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source +nvm script only when using it, and will create a function for `node`, `npm`, `pnpm`, `yarn`, and the +command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with +default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: + +```zsh +zstyle ':omz:plugins:nvm' lazy yes +``` + +Then, to define extra commands that will also trigger nvm load, you can use a similar syntax, adding as many +as you want: + +```zsh +zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ... +``` + +#### `.nvmrc` autoload + +If set, the plugin will automatically load a node version when if finds a +[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node +version to load. This can be done, similar as previous options, adding: + +```zsh +zstyle ':omz:plugins:nvm' autoload true +``` diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 1fb4d238b..ec583cc2d 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -16,14 +16,41 @@ fi # Note: nvm is a function so we need to use `which` which nvm &>/dev/null && return -if (( $+NVM_LAZY )); then - # Call nvm when first using nvm, node, npm, pnpm, yarn or $NVM_LAZY_CMD - function nvm node npm pnpm yarn $NVM_LAZY_CMD { - unfunction nvm node npm pnpm yarn $NVM_LAZY_CMD - # Load nvm if it exists in $NVM_DIR - [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" - "$0" "$@" - } +# TODO: 2022-11-11: Remove soft-deprecate options +if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then + # Get list of NVM_* variable settings defined + local -a used_vars + used_vars=(${(o)parameters[(I)NVM_(AUTOLOAD|LAZY|LAZY_CMD)]}) + # Nicely print the list in the style `var1, var2 and var3` + echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n" + if (( $+NVM_AUTOLOAD )); then + echo " zstyle ':omz:plugins:nvm' autoload true" + zstyle ':omz:plugins:nvm' autoload yes + fi + if (( $+NVM_LAZY )); then + echo " zstyle ':omz:plugins:nvm' lazy true" + zstyle ':omz:plugins:nvm' lazy yes + fi + if (( $+NVM_LAZY_CMD )); then + echo " zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD" + zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD + fi + echo "$reset_color" + unset used_vars NVM_AUTOLOAD NVM_LAZY NVM_LAZY_CMD +fi + +if zstyle -t ':omz:plugins:nvm' lazy; then + # Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd + zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd + eval " + function nvm node npm pnpm yarn $nvm_lazy_cmd { + unfunction nvm node npm pnpm yarn $nvm_lazy_cmd + # Load nvm if it exists in \$NVM_DIR + [[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\" + \"\$0\" \"\$@\" + } + " + unset nvm_lazy_cmd elif [[ -f "$NVM_DIR/nvm.sh" ]]; then # Load nvm if it exists in $NVM_DIR source "$NVM_DIR/nvm.sh" @@ -33,7 +60,7 @@ fi # Autoload nvm when finding a .nvmrc file in the current directory # Adapted from: https://github.com/nvm-sh/nvm#zsh -if (( $+NVM_AUTOLOAD )); then +if zstyle -t ':omz:plugins:nvm' autoload; then load-nvmrc() { local node_version="$(nvm version)" local nvmrc_path="$(nvm_find_nvmrc)" @@ -70,4 +97,4 @@ for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_complet fi done -unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion +unset NVM_HOMEBREW nvm_completion From 5bce72ef57255ab1c23d8fb753417859afe6e0f0 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 15 Nov 2022 20:27:12 +0100 Subject: [PATCH 47/77] docs(yarn): follow omz `zstyle` bools standard --- plugins/yarn/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index 9c16ff2c3..cdda2026c 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -15,7 +15,7 @@ It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`. To disable this feature, set the following style in your `.zshrc`: ```zsh -zstyle ':omz:plugins:yarn' global-path false +zstyle ':omz:plugins:yarn' global-path no ``` ## Aliases From 5ab517361a4215d2f777023fc1e772fe79496713 Mon Sep 17 00:00:00 2001 From: Ruslan Tursunov Date: Thu, 17 Nov 2022 13:54:01 +0300 Subject: [PATCH 48/77] feat(git): add `gcn` alias (#10836) --- 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 f1c8b81c4..3beb0890a 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -35,6 +35,7 @@ plugins=(... git) | gbss | git bisect start | | gc | git commit -v | | gc! | git commit -v --amend | +| gcn | git commit -v --no-edit | | gcn! | git commit -v --no-edit --amend | | gca | git commit -v -a | | gca! | git commit -v -a --amend | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 26f4beeb3..69745730c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -84,6 +84,7 @@ alias gbss='git bisect start' alias gc='git commit -v' alias gc!='git commit -v --amend' +alias gcn='git commit -v --no-edit' alias gcn!='git commit -v --no-edit --amend' alias gca='git commit -v -a' alias gca!='git commit -v -a --amend' From d93f3174504f8a0c21aef6998714e3b67ba82606 Mon Sep 17 00:00:00 2001 From: Carlo Date: Sun, 20 Nov 2022 08:36:20 +0100 Subject: [PATCH 49/77] fix(init): prevent multiple compdump compilations (#11345) Closes #11341 --- oh-my-zsh.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 29d39ca23..e94c2f417 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -143,7 +143,10 @@ fi unset zcompdump_revision zcompdump_fpath zcompdump_refresh # zcompile the completion dump file if the .zwc is older or missing. -zrecompile -q -p "$ZSH_COMPDUMP" && command rm -f "$ZSH_COMPDUMP.zwc.old" +if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then + zrecompile -q -p "$ZSH_COMPDUMP" + command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock" +fi # Load all of the config files in ~/oh-my-zsh that end in .zsh # TIP: Add files you don't want in git to .gitignore From 96976736166998a980cc3d9570db4c0b594460e3 Mon Sep 17 00:00:00 2001 From: Brenex Date: Mon, 21 Nov 2022 05:23:16 -0500 Subject: [PATCH 50/77] docs(aliases): fix typos (#11348) Co-authored-by: Carlo Sala --- plugins/aliases/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index 66fd84584..4e77f67b3 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -15,14 +15,14 @@ Requirements: Python needs to be installed. ## Usage -- `acs`: show all aliases by group. +- `acs`: show all aliases by group -- `acs -h/--help`: print help mesage. +- `acs -h/--help`: print help mesage -- `acs `: filter aliases by `` and highlight. +- `acs `: filter aliases by `` and highlight -- `acs -g /--group `. Multiple uses of the flag show all groups, +- `acs -g /--group `: show only aliases for group ``. Multiple uses of the flag show all groups -- `acs --groups-only`: show only group names +- `acs --groups`: show only group names ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png) From fe83581a20ab12010e9168977dc633c9da2924e1 Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Mon, 21 Nov 2022 05:24:10 -0500 Subject: [PATCH 51/77] fix(last-working-dir): use builtin `pwd` (#11346) --- plugins/last-working-dir/last-working-dir.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 905a02a70..684972cc1 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -9,7 +9,7 @@ chpwd_last_working_dir() { [[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0 # Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}" - pwd >| "$cache_file" + builtin pwd >| "$cache_file" } # Changes directory to the last working directory From 8ef9abc9621321c41e89c578bc6f12176696f36c Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Wed, 23 Nov 2022 10:23:11 +0100 Subject: [PATCH 52/77] feat(pre-commit) add aliases (#10707) --- plugins/pre-commit/README.md | 19 +++++++++++++++++++ plugins/pre-commit/pre-commit.plugin.zsh | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 plugins/pre-commit/README.md create mode 100644 plugins/pre-commit/pre-commit.plugin.zsh diff --git a/plugins/pre-commit/README.md b/plugins/pre-commit/README.md new file mode 100644 index 000000000..e6d80d369 --- /dev/null +++ b/plugins/pre-commit/README.md @@ -0,0 +1,19 @@ +# Pre-commit plugin + +This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/). + +To use this plugin, add it to the plugins array in your zshrc file: + +```zsh +plugins=(... pre-commit) +``` + +## Aliases + +| Alias | Command | Description | +| ------- | -------------------------------------- | ------------------------------------------------------ | +| prc | `pre-commit` | The `pre-commit` command | +| prcau | `pre-commit autoupdate` | Update hooks automatically | +| prcr | `pre-commit run` | The `pre-commit run` command | +| prcra | `pre-commit run --all-files` | Run pre-commit hooks on all files | +| prcrf | `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 new file mode 100644 index 000000000..c3d0c6290 --- /dev/null +++ b/plugins/pre-commit/pre-commit.plugin.zsh @@ -0,0 +1,8 @@ +# Aliases for pre-commit +alias prc='pre-commit' + +alias prcau='pre-commit autoupdate' + +alias prcr='pre-commit run' +alias prcra='pre-commit run --all-files' +alias prcrf='pre-commit run --files' From 5485d70df2cefa9374c477425d2c1c84646a7d49 Mon Sep 17 00:00:00 2001 From: Luis Serra <74016165+serrovsky@users.noreply.github.com> Date: Wed, 23 Nov 2022 17:24:08 +0000 Subject: [PATCH 53/77] feat(fluxcd): add completion for flux (#11350) --- plugins/fluxcd/README.md | 9 +++++++++ plugins/fluxcd/fluxcd.plugin.zsh | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/fluxcd/README.md create mode 100644 plugins/fluxcd/fluxcd.plugin.zsh diff --git a/plugins/fluxcd/README.md b/plugins/fluxcd/README.md new file mode 100644 index 000000000..9723fcc6b --- /dev/null +++ b/plugins/fluxcd/README.md @@ -0,0 +1,9 @@ +# FluxCD plugin + +This plugin adds completion for [FluxCD](https://fluxcd.io), an open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. + +To use it, add `fluxcd` to the plugins array in your zshrc file: + +```zsh +plugins=(... fluxcd) +``` diff --git a/plugins/fluxcd/fluxcd.plugin.zsh b/plugins/fluxcd/fluxcd.plugin.zsh new file mode 100644 index 000000000..d30866a06 --- /dev/null +++ b/plugins/fluxcd/fluxcd.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the FluxCD CLI (flux). +if (( ! $+commands[flux] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `flux`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_flux" ]]; then + typeset -g -A _comps + autoload -Uz _flux + _comps[flux]=_flux +fi + +flux completion zsh >| "$ZSH_CACHE_DIR/completions/_flux" &| From a473c0cb4ad325de211f37388b0ff6ae435b6df4 Mon Sep 17 00:00:00 2001 From: Luis Serra <74016165+serrovsky@users.noreply.github.com> Date: Wed, 23 Nov 2022 17:24:46 +0000 Subject: [PATCH 54/77] feat(mongo-atlas): add completion for atlas (#11349) --- plugins/mongo-atlas/README.md | 10 ++++++++++ plugins/mongo-atlas/mongo-atlas.plugin.zsh | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 plugins/mongo-atlas/README.md create mode 100644 plugins/mongo-atlas/mongo-atlas.plugin.zsh diff --git a/plugins/mongo-atlas/README.md b/plugins/mongo-atlas/README.md new file mode 100644 index 000000000..ef1b5e0d2 --- /dev/null +++ b/plugins/mongo-atlas/README.md @@ -0,0 +1,10 @@ +# MongoDB Atlas plugin + +This plugin adds completion for [Atlas](https://www.mongodb.com/docs/atlas/cli/stable/) a command line interface built specifically for +MongoDB Atlas. + +To use it, add `mongo-atlas` to the plugins array in your zshrc file: + +```zsh +plugins=(... mongo-atlas) +``` diff --git a/plugins/mongo-atlas/mongo-atlas.plugin.zsh b/plugins/mongo-atlas/mongo-atlas.plugin.zsh new file mode 100644 index 000000000..6762c909e --- /dev/null +++ b/plugins/mongo-atlas/mongo-atlas.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the Mongo Atlas CLI (atlas). +if (( ! $+commands[atlas] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `atlas`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_atlas" ]]; then + typeset -g -A _comps + autoload -Uz _atlas + _comps[atlas]=_atlas +fi + +atlas completion zsh >| "$ZSH_CACHE_DIR/completions/atlas" &| From da7ea13ba928a36c0b41cb520b0cc192f6389143 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Wed, 23 Nov 2022 10:56:26 -0700 Subject: [PATCH 55/77] fix(avit): replace deprecated GREP_COLOR (#11168) --- themes/avit.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index f90ba331b..1279ea919 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -82,4 +82,4 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}" # LS colors, made with https://geoff.greer.fm/lscolors/ export LSCOLORS="exfxcxdxbxegedabagacad" export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' -export GREP_COLOR='1;33' +export GREP_COLORS='mt=1;33' From a4392cfc16ce6f1ddf1fd085819913ee26dc6189 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 15 Nov 2022 19:40:06 +0100 Subject: [PATCH 56/77] feat(docker): update completion Taken from https://github.com/docker/cli/blob/79dca7a38e9969f9d0694d85adbaf13394d893ac/contrib/completion/zsh/_docker Closes #10826 --- plugins/docker/_docker | 54 +++++++++++++----------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 8ee35abcf..e6a12d774 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -567,7 +567,7 @@ __docker_container_commands() { "cp:Copy files/folders between a container and the local filesystem" "create:Create a new container" "diff:Inspect changes on a container's filesystem" - "exec:Run a command in a running container" + "exec:Execute a command in a running container" "export:Export a container's filesystem as a tar archive" "inspect:Display detailed information on one or more containers" "kill:Kill one or more running containers" @@ -579,7 +579,7 @@ __docker_container_commands() { "rename:Rename a container" "restart:Restart one or more containers" "rm:Remove one or more containers" - "run:Run a command in a new container" + "run:Create and run a new container from an image" "start:Start one or more stopped containers" "stats:Display a live stream of container(s) resource usage statistics" "stop:Stop one or more running containers" @@ -650,6 +650,7 @@ __docker_container_subcommand() { "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid" "($help)--privileged[Give extended privileges to this container]" + "($help -q --quiet)"{-q,--quiet}"[Suppress the pull output]" "($help)--read-only[Mount the container's root filesystem as read only]" "($help)*--security-opt=[Security options]:security option: " "($help)*--shm-size=[Size of '/dev/shm' (format is '')]:shm size: " @@ -802,7 +803,7 @@ __docker_container_subcommand() { "($help -a --all)"{-a,--all}"[Show all containers]" \ "($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ - "($help)--format=[Pretty-print containers using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ @@ -907,7 +908,7 @@ __docker_container_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ - "($help)--format=[Pretty-print images using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help)--no-stream[Disable streaming stats and only pull the first result]" \ "($help)--no-trunc[Do not truncate output]" \ "($help -)*:containers:__docker_complete_running_containers" && ret=0 @@ -973,8 +974,8 @@ __docker_image_commands() { "load:Load an image from a tar archive or STDIN" "ls:List images" "prune:Remove unused images" - "pull:Pull an image or a repository from a registry" - "push:Push an image or a repository to a registry" + "pull:Download an image from a registry" + "push:Upload an image to a registry" "rm:Remove one or more images" "save:Save one or more images to a tar archive (streamed to STDOUT by default)" "tag:Tag an image into a repository" @@ -1060,7 +1061,7 @@ __docker_image_subcommand() { "($help -a --all)"{-a,--all}"[Show all images]" \ "($help)--digests[Show digests]" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \ - "($help)--format=[Pretty-print images using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \ "($help -): :__docker_complete_repositories" && ret=0 @@ -1082,7 +1083,7 @@ __docker_image_subcommand() { (push) _arguments $(__docker_arguments) \ $opts_help \ - "($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \ + "($help -a --all-tags)"{-a,--all-tags}"[Push all tags of an image to the repository]" \ "($help)--disable-content-trust[Skip image signing]" \ "($help -): :__docker_complete_images" && ret=0 ;; @@ -1292,7 +1293,7 @@ __docker_network_subcommand() { $opts_help \ "($help)--no-trunc[Do not truncate the output]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \ - "($help)--format=[Pretty-print networks using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0 ;; (prune) @@ -2050,7 +2051,7 @@ __docker_service_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \ - "($help)--format=[Pretty-print services using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 ;; (rm|remove) @@ -2253,7 +2254,7 @@ __docker_stack_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \ - "($help)--format=[Pretty-print services using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ "($help -):stack:__docker_complete_stacks" && ret=0 ;; @@ -2520,7 +2521,7 @@ __docker_volume_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \ - "($help)--format=[Pretty-print volumes using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 ;; (prune) @@ -2582,10 +2583,8 @@ __docker_context_subcommand() { (create) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \ "($help)--description=[Description of the context]:description:" \ "($help)--docker=[Set the docker endpoint]:docker:" \ - "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \ "($help)--from=[Create context from a named context]:from:__docker_complete_contexts" \ "($help -):name: " && ret=0 ;; @@ -2607,10 +2606,8 @@ __docker_context_subcommand() { (update) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \ "($help)--description=[Description of the context]:description:" \ "($help)--docker=[Set the docker endpoint]:docker:" \ - "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \ "($help -):name:" && ret=0 ;; esac @@ -2734,9 +2731,6 @@ __docker_subcommand() { "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \ "($help)--bip=[Network bridge IP]:IP address: " \ "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \ - "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \ - "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ - "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \ "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \ "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \ "($help)--containerd-namespace=[Containerd namespace to use]:containerd namespace:" \ @@ -2778,7 +2772,7 @@ __docker_subcommand() { "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \ "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ "($help)--raw-logs[Full timestamps without ANSI coloring]" \ - "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \ + "($help)*--registry-mirror=[Preferred registry mirror]:registry mirror: " \ "($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \ "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \ "($help)--selinux-enabled[Enable selinux support]" \ @@ -2795,22 +2789,6 @@ __docker_subcommand() { "($help)--validate[Validate daemon configuration and exit]" && ret=0 case $state in - (cluster-store) - if compset -P '*://'; then - _message 'host:port' && ret=0 - else - store=('consul' 'etcd' 'zk') - _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0 - fi - ;; - (cluster-store-options) - if compset -P '*='; then - _files && ret=0 - else - opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path') - _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0 - fi - ;; (users-groups) if compset -P '*:'; then _groups && ret=0 @@ -3095,6 +3073,7 @@ _docker() { _arguments $(__docker_arguments) -C \ "(: -)"{-h,--help}"[Print usage]" \ "($help)--config[Location of client config files]:path:_directories" \ + "($help -c --context)"{-c=,--context=}"[Execute the command in a docker context]:context:__docker_complete_contexts" \ "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ @@ -3110,7 +3089,8 @@ _docker() { local host=${opt_args[-H]}${opt_args[--host]} local config=${opt_args[--config]} - local docker_options="${host:+--host $host} ${config:+--config $config}" + local context=${opt_args[-c]}${opt_args[--context]} + local docker_options="${host:+--host $host} ${config:+--config $config} ${context:+--context $context} " case $state in (command) From 1c06ea24fb2176e28facf34b7c2ed2bfb3c79eaa Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 15 Nov 2022 20:05:13 +0100 Subject: [PATCH 57/77] chore(docker): sort and reorganize aliases --- plugins/docker/README.md | 86 +++++++++++++++----------------- plugins/docker/docker.plugin.zsh | 32 +++++------- 2 files changed, 52 insertions(+), 66 deletions(-) diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 606690f14..b865d53ed 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -13,18 +13,15 @@ https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker ## Settings -By default, the completion doesn't allow option-stacking, meaning if you try to -complete `docker run -it ` it won't work, because you're _stacking_ the -`-i` and `-t` options. +By default, the completion doesn't allow option-stacking, meaning if you try to complete +`docker run -it ` it won't work, because you're _stacking_ the `-i` and `-t` options. -[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding -the lines below to your zshrc file**, but be aware of the side effects: +[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding the lines below to your zshrc +file**, but be aware of the side effects: -> This enables Zsh to understand commands like `docker run -it -> ubuntu`. However, by enabling this, this also makes Zsh complete -> `docker run -u` with `docker run -uapprox` which is not valid. The -> users have to put the space or the equal sign themselves before trying -> to complete. +> This enables Zsh to understand commands like `docker run -it ubuntu`. However, by enabling this, this also +> makes Zsh complete `docker run -u` with `docker run -uapprox` which is not valid. The users have to put +> the space or the equal sign themselves before trying to complete. > > Therefore, this behavior is disabled by default. To enable it: > @@ -35,39 +32,36 @@ the lines below to your zshrc file**, but be aware of the side effects: ## Aliases -| Alias | Command | Description | -| :------ | :-------------------------- | :--------------------------------------------------------------------------------------- | -| dbl | `docker build` | Build an image from a Dockerfile | -| dcin | `docker container inspect` | Display detailed information on one or more containers | -| dlo | `docker container logs` | Fetch the logs of a docker container | -| dcls | `docker container ls` | List all the running docker containers | -| dclsa | `docker container ls -a` | List all running and stopped containers | -| dpo | `docker container port` | List port mappings or a specific mapping for the container | -| dpu | `docker pull` | Pull an image or a repository from a registry | -| dr | `docker container run` | Create a new container and start it using the specified command | -| drit | `docker container run -it` | Create a new container and start it in an interactive shell | -| drm | `docker container rm` | Remove the specified container(s) | -| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | -| dst | `docker container start` | Start one or more stopped containers | -| dstp | `docker container stop` | Stop one or more running containers | -| dtop | `docker top` | Display the running processes of a container | -| dxc | `docker container exec` | Run a new command in a running container | -| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell | -| | | **Docker Images** | -| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) | -| dii | `docker image inspect` | Display detailed information on one or more images | -| dils | `docker image ls` | List docker images | -| dipu | `docker image push` | Push an image or repository to a remote registry | -| dirm | `docker image rm` | Remove one or more images | -| dit | `docker image tag` | Add a name and tag to a particular image | -| | | **Docker Network** | -| dnc | `docker network create` | Create a new network | -| dncn | `docker network connect` | Connect a container to a network | -| dndcn | `docker network disconnect` | Disconnect a container from a network | -| dni | `docker network inspect` | Return information about one or more networks | -| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | -| dnrm | `docker network rm` | Remove one or more networks | -| | | **Docker Volume** | -| dvi | `docker volume inspect` | Display detailed information about one or more volumes | -| dvls | `docker volume ls` | List all the volumes known to docker | -| dvprune | `docker volume prune` | Cleanup dangling volumes | +| Alias | Command | Description | +| :------ | :---------------------------- | :--------------------------------------------------------------------------------------- | +| dbl | `docker build` | Build an image from a Dockerfile | +| dcin | `docker container inspect` | Display detailed information on one or more containers | +| dcls | `docker container ls` | List all the running docker containers | +| dclsa | `docker container ls -a` | List all running and stopped containers | +| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) | +| dii | `docker image inspect` | Display detailed information on one or more images | +| dils | `docker image ls` | List docker images | +| dipu | `docker image push` | Push an image or repository to a remote registry | +| dirm | `docker image rm` | Remove one or more images | +| dit | `docker image tag` | Add a name and tag to a particular image | +| dlo | `docker container logs` | Fetch the logs of a docker container | +| dnc | `docker network create` | Create a new network | +| dncn | `docker network connect` | Connect a container to a network | +| dndcn | `docker network disconnect` | Disconnect a container from a network | +| dni | `docker network inspect` | Return information about one or more networks | +| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | +| dnrm | `docker network rm` | Remove one or more networks | +| dpo | `docker container port` | List port mappings or a specific mapping for the container | +| dpu | `docker pull` | Pull an image or a repository from a registry | +| dr | `docker container run` | Create a new container and start it using the specified command | +| drit | `docker container run -it` | Create a new container and start it in an interactive shell | +| drm | `docker container rm` | Remove the specified container(s) | +| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | +| dst | `docker container start` | Start one or more stopped containers | +| dstp | `docker container stop` | Stop one or more running containers | +| dtop | `docker top` | Display the running processes of a container | +| dvi | `docker volume inspect` | Display detailed information about one or more volumes | +| dvls | `docker volume ls` | List all the volumes known to docker | +| dvprune | `docker volume prune` | Cleanup dangling volumes | +| dxc | `docker container exec` | Run a new command in a running container | +| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell | diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 9c8ad8a28..483b3b97e 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -1,39 +1,31 @@ alias dbl='docker build' -alias dpu='docker pull' -alias dtop='docker top' - -# docker containers alias dcin='docker container inspect' -alias dlo='docker container logs' alias dcls='docker container ls' alias dclsa='docker container ls -a' -alias dpo='docker container port' -alias dr='docker container run' -alias drit='docker container run -it' -alias drm='docker container rm' -alias 'drm!'='docker container rm -f' -alias dst='docker container start' -alias dstp='docker container stop' -alias dxc='docker container exec' -alias dxcit='docker container exec -it' - -# docker images alias dib='docker image build' alias dii='docker image inspect' alias dils='docker image ls' alias dipu='docker image push' alias dirm='docker image rm' alias dit='docker image tag' - -# docker network +alias dlo='docker container logs' alias dnc='docker network create' alias dncn='docker network connect' alias dndcn='docker network disconnect' alias dni='docker network inspect' alias dnls='docker network ls' alias dnrm='docker network rm' - -# docker volume +alias dpo='docker container port' +alias dpu='docker pull' +alias dr='docker container run' +alias drit='docker container run -it' +alias drm='docker container rm' +alias 'drm!'='docker container rm -f' +alias dst='docker container start' +alias dstp='docker container stop' +alias dtop='docker top' alias dvi='docker volume inspect' alias dvls='docker volume ls' alias dvprune='docker volume prune' +alias dxc='docker container exec' +alias dxcit='docker container exec -it' From c35ca17258dd870f1724eeb92e9077177d2e3bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Bernard=20Ara=C3=BAjo?= Date: Tue, 15 Nov 2022 20:05:33 +0100 Subject: [PATCH 58/77] feat(docker): add `dsta` alias Closes #11089 --- plugins/docker/README.md | 1 + plugins/docker/docker.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/docker/README.md b/plugins/docker/README.md index b865d53ed..040a168d6 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -58,6 +58,7 @@ file**, but be aware of the side effects: | drm | `docker container rm` | Remove the specified container(s) | | drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | | dst | `docker container start` | Start one or more stopped containers | +| dsta | `docker stop $(docker ps -q)` | Stop all running containers | | dstp | `docker container stop` | Stop one or more running containers | | dtop | `docker top` | Display the running processes of a container | | dvi | `docker volume inspect` | Display detailed information about one or more volumes | diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 483b3b97e..737803651 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -22,6 +22,7 @@ alias drit='docker container run -it' alias drm='docker container rm' alias 'drm!'='docker container rm -f' alias dst='docker container start' +alias dsta='docker stop $(docker ps -q)' alias dstp='docker container stop' alias dtop='docker top' alias dvi='docker volume inspect' From 1aa58d42a52b8fa39f16ad169fc405f276c36ae5 Mon Sep 17 00:00:00 2001 From: jzhang046 <25826821+jzhang046@users.noreply.github.com> Date: Sun, 27 Nov 2022 17:54:24 +0800 Subject: [PATCH 59/77] fix(changelog): generate correct commit link in markdown (#11356) --- tools/changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 6489a3cb2..a5cc468f2 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -209,7 +209,7 @@ function display-release { case "$output" in raw) printf '%s' "$hash" ;; text) printf '\e[33m%s\e[0m' "$hash" ;; # red - md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" ;; + md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" "$hash" ;; esac } From 66addc8b45c93f7661a5d8bba93b7b4afcbc23de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lopes?= <85288424+agnlopes@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:35:57 +0100 Subject: [PATCH 60/77] feat(skaffold): add completion (#11357) --- plugins/skaffold/README.md | 9 +++++++++ plugins/skaffold/skaffold.plugin.zsh | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/skaffold/README.md create mode 100644 plugins/skaffold/skaffold.plugin.zsh diff --git a/plugins/skaffold/README.md b/plugins/skaffold/README.md new file mode 100644 index 000000000..4ee12c666 --- /dev/null +++ b/plugins/skaffold/README.md @@ -0,0 +1,9 @@ +# Skaffold plugin (Autocompletion) + +This plugin adds completion for [Skaffold](https://skaffold.dev) + +To use it, add `skaffold` to the plugins array in your zshrc file: + +```zsh +plugins=(... skaffold) +``` diff --git a/plugins/skaffold/skaffold.plugin.zsh b/plugins/skaffold/skaffold.plugin.zsh new file mode 100644 index 000000000..8296c450c --- /dev/null +++ b/plugins/skaffold/skaffold.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for skaffold +if (( ! $+commands[skaffold] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `skaffold`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_skaffold" ]]; then + typeset -g -A _comps + autoload -Uz _skaffold + _comps[skaffold]=_skaffold +fi + +skaffold completion zsh >| "$ZSH_CACHE_DIR/completions/_skaffold" &| From a051eb04b88cb0a876d1f3d68559d228a14dccf0 Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Thu, 1 Dec 2022 12:34:38 +0100 Subject: [PATCH 61/77] feat(mvn): add completion for Vaadin (#11362) --- plugins/mvn/mvn.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 1b9141f21..151fbd2a6 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -283,6 +283,8 @@ function listMavenCompletions { toolchain:toolchain #liberty liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature + # vaadin + vaadin:prepare-frontend vaadin:build-frontend vaadin:clean-frontend vaadin:dance # options "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile=" From 64bc22aee4d32eb64ee918fc9e63318b68979070 Mon Sep 17 00:00:00 2001 From: Carlo Date: Thu, 1 Dec 2022 19:44:48 +0100 Subject: [PATCH 62/77] feat(nvm): add `silent-autoload` setting (#11363) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Regulski Closes #10942 --- plugins/nvm/README.md | 10 +++++++++- plugins/nvm/nvm.plugin.zsh | 12 +++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index 4c6312e6e..d3fd980be 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -48,5 +48,13 @@ If set, the plugin will automatically load a node version when if finds a version to load. This can be done, similar as previous options, adding: ```zsh -zstyle ':omz:plugins:nvm' autoload true +zstyle ':omz:plugins:nvm' autoload yes ``` + +To remove the output generated by NVM when autoloading, you can set the following option: + +```zsh +zstyle ':omz:plugins:nvm' silent-autoload yes +``` + +Note: _this will not remove regular `nvm` output_ diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index ec583cc2d..c5799c88e 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -24,11 +24,11 @@ if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then # Nicely print the list in the style `var1, var2 and var3` echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n" if (( $+NVM_AUTOLOAD )); then - echo " zstyle ':omz:plugins:nvm' autoload true" + echo " zstyle ':omz:plugins:nvm' autoload yes" zstyle ':omz:plugins:nvm' autoload yes fi if (( $+NVM_LAZY )); then - echo " zstyle ':omz:plugins:nvm' lazy true" + echo " zstyle ':omz:plugins:nvm' lazy yes" zstyle ':omz:plugins:nvm' lazy yes fi if (( $+NVM_LAZY_CMD )); then @@ -61,9 +61,11 @@ fi # Autoload nvm when finding a .nvmrc file in the current directory # Adapted from: https://github.com/nvm-sh/nvm#zsh if zstyle -t ':omz:plugins:nvm' autoload; then - load-nvmrc() { + function load-nvmrc { local node_version="$(nvm version)" local nvmrc_path="$(nvm_find_nvmrc)" + local nvm_silent="" + zstyle -t ':omz:plugins:nvm' silent-autoload && _nvm_silent="--silent" if [[ -n "$nvmrc_path" ]]; then local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") @@ -71,11 +73,11 @@ if zstyle -t ':omz:plugins:nvm' autoload; then if [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install elif [[ "$nvmrc_node_version" != "$node_version" ]]; then - nvm use + nvm use $nvm_silent fi elif [[ "$node_version" != "$(nvm version default)" ]]; then echo "Reverting to nvm default version" - nvm use default + nvm use default $nvm_silent fi } From fc44c49cca9d5e499097392d3f42b1375d0253ba Mon Sep 17 00:00:00 2001 From: Zeragamba Date: Thu, 1 Dec 2022 13:49:41 -0500 Subject: [PATCH 63/77] fix(nvm): trim non-printable chars from .nvmrc (#10997) --- plugins/nvm/nvm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index c5799c88e..a4ff29cf1 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -68,7 +68,7 @@ if zstyle -t ':omz:plugins:nvm' autoload; then zstyle -t ':omz:plugins:nvm' silent-autoload && _nvm_silent="--silent" if [[ -n "$nvmrc_path" ]]; then - local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") + local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]')) if [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install From 7ea8a93bb8fb04a070960048aa0b5dca639456a8 Mon Sep 17 00:00:00 2001 From: Mohammad Parvin Date: Fri, 2 Dec 2022 16:19:00 +0330 Subject: [PATCH 64/77] feat(helm): add aliases (#11361) Co-authored-by: Carlo Sala --- plugins/helm/README.md | 11 ++++++++++- plugins/helm/helm.plugin.zsh | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/helm/README.md b/plugins/helm/README.md index 49844c78f..8be024bfb 100644 --- a/plugins/helm/README.md +++ b/plugins/helm/README.md @@ -1,9 +1,18 @@ # Helm plugin -This plugin adds completion for [Helm](https://helm.sh/), the Kubernetes package manager. +This plugin adds completion and aliases for [Helm](https://helm.sh/), the Kubernetes package manager. To use it, add `helm` to the plugins array in your zshrc file: ```zsh plugins=(... helm) ``` + +## Aliases + +| Alias | Full command | +| ----- | ------------ | +| h | helm | +| hin | helm install | +| hse | helm search | +| hup | helm upgrade | diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index 151c43d88..7fc05be98 100644 --- a/plugins/helm/helm.plugin.zsh +++ b/plugins/helm/helm.plugin.zsh @@ -11,3 +11,8 @@ else source "$ZSH_CACHE_DIR/completions/_helm" helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null &| fi + +alias h='helm' +alias hin='helm install' +alias hse='helm search' +alias hup='helm upgrade' From 3a9322b9a0698a3861277890f791b43e727cccc5 Mon Sep 17 00:00:00 2001 From: Noam Okman Date: Mon, 5 Dec 2022 15:18:18 +0200 Subject: [PATCH 65/77] feat(yarn): add format alias (#11368) --- plugins/yarn/README.md | 1 + plugins/yarn/yarn.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index cdda2026c..270bf6b7f 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -29,6 +29,7 @@ zstyle ':omz:plugins:yarn' global-path no | yb | `yarn build` | Run the build script defined in `package.json` | | ycc | `yarn cache clean` | Clean yarn's global cache of packages | | yd | `yarn dev` | Run the dev script defined in `package.json` | +| yf | `yarn format` | Run the dev script defined in `package.json` | | yga | `yarn global add` | Install packages globally on your operating system | | ygls | `yarn global list` | Lists global installed packages | | ygrm | `yarn global remove` | Remove global installed packages from your OS | diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index bcb8661cf..7ba710df7 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -17,6 +17,7 @@ alias yap="yarn add --peer" alias yb="yarn build" alias ycc="yarn cache clean" alias yd="yarn dev" +alias yf="yarn format" alias yga="yarn global add" alias ygls="yarn global list" alias ygrm="yarn global remove" From 585e7138b556db89715eb2a850f8959fdf527384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Regulski?= Date: Tue, 6 Dec 2022 18:22:13 +0100 Subject: [PATCH 66/77] fix(nvm): omit message when silent-autoload is enabled (#11371) --- plugins/nvm/nvm.plugin.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index a4ff29cf1..20697d67d 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -65,7 +65,7 @@ if zstyle -t ':omz:plugins:nvm' autoload; then local node_version="$(nvm version)" local nvmrc_path="$(nvm_find_nvmrc)" local nvm_silent="" - zstyle -t ':omz:plugins:nvm' silent-autoload && _nvm_silent="--silent" + zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent" if [[ -n "$nvmrc_path" ]]; then local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]')) @@ -76,7 +76,10 @@ if zstyle -t ':omz:plugins:nvm' autoload; then nvm use $nvm_silent fi elif [[ "$node_version" != "$(nvm version default)" ]]; then - echo "Reverting to nvm default version" + if [[ -z $nvm_silent ]]; then + echo "Reverting to nvm default version" + fi + nvm use default $nvm_silent fi } From 658eb01d82c01d82b4263b3dc59e15232cb4cdaf Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 6 Dec 2022 22:51:52 +0100 Subject: [PATCH 67/77] refactor(kubectl): standarize completion generation --- plugins/kubectl/kubectl.plugin.zsh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 095d2b328..b415d1ad8 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -1,15 +1,17 @@ -if (( $+commands[kubectl] )); then - # 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/_kubectl" ]]; then - kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null - source "$ZSH_CACHE_DIR/completions/_kubectl" - else - source "$ZSH_CACHE_DIR/completions/_kubectl" - kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null &| - fi +if (( ! $+commands[kubectl] )); then + return fi +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `kubectl`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then + typeset -g -A _comps + autoload -Uz _kubectl + _comps[kubectl]=_kubectl +fi + +kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &| + # This command is used a LOT both below and in daily life alias k=kubectl From b692ff2e1597816563cbdaeeedf0966ad9babeca Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 7 Dec 2022 12:18:51 +0100 Subject: [PATCH 68/77] fix(kubectl): redirect stderr in completion generation Fixes #11364 --- plugins/kubectl/kubectl.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index b415d1ad8..315d3ce93 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -10,7 +10,7 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then _comps[kubectl]=_kubectl fi -kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &| +kubectl completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_kubectl" &| # This command is used a LOT both below and in daily life alias k=kubectl From f4dc8c5be365668810783ced01a86ff8f251bfd7 Mon Sep 17 00:00:00 2001 From: fedor <60283525+izumrudik@users.noreply.github.com> Date: Thu, 8 Dec 2022 14:38:13 +0300 Subject: [PATCH 69/77] fix(tmux): use `$...SESSION_NAME` while attaching (#10946) --- plugins/tmux/tmux.plugin.zsh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index b9bb66d59..311c2e6a9 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -73,7 +73,11 @@ function _zsh_tmux_plugin_run() { [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u) # Try to connect to an existing session. - [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME + else + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + fi # If failed, just run tmux, fixing the TERM variable if requested. if [[ $? -ne 0 ]]; then @@ -83,9 +87,9 @@ function _zsh_tmux_plugin_run() { tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") fi if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then - $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME + $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME else - $tmux_cmd new-session + $tmux_cmd new-session fi fi From cc5100d1e9e3d843ab93a12a5b0bac71ae0425f3 Mon Sep 17 00:00:00 2001 From: Neil Girdhar Date: Fri, 9 Dec 2022 04:07:52 -0500 Subject: [PATCH 70/77] feat(pip): add several aliases (#10647) --- plugins/pip/README.md | 8 ++++++++ plugins/pip/pip.plugin.zsh | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plugins/pip/README.md b/plugins/pip/README.md index 88d88227e..70d40c79f 100644 --- a/plugins/pip/README.md +++ b/plugins/pip/README.md @@ -22,6 +22,14 @@ the next time you autocomplete `pip install`. | Alias | Description | | :------- | :-------------------------------------------- | +| pipi | Install packages | +| pipig | Install package from GitHub repository | +| pipigb | Install package from GitHub branch | +| pipigp | Install package from GitHub pull request | +| pipu | Upgrade packages | +| pipun | Uninstall packages | +| pipgi | Grep through installed packages | +| piplo | List outdated packages | | pipreq | Create requirements file | | pipir | Install packages from `requirements.txt` file | | pipupall | Update all installed packages | diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 90e39e118..bf1aafd4a 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -88,6 +88,12 @@ else alias pip="noglob pip" fi +alias pipi="pip install" +alias pipu="pip install --upgrade" +alias pipun="pip uninstall" +alias pipgi="pip freeze | grep" +alias piplo="pip list -o" + # Create requirements file alias pipreq="pip freeze > requirements.txt" @@ -102,10 +108,28 @@ function pipupall { pip list --outdated | awk 'NR > 2 { print $1 }' | ${=xargs} pip install --upgrade } -# Uninstalled all installed packages +# Uninstall all installed packages function pipunall { # non-GNU xargs does not support nor need `--no-run-if-empty` local xargs="xargs --no-run-if-empty" xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" pip list --format freeze | cut -d= -f1 | ${=xargs} pip uninstall } + +# Install from GitHub repository +function pipig { + pip install "git+https://github.com/$1.git" +} +compdef _pip pipig + +# Install from GitHub branch +function pipigb { + pip install "git+https://github.com/$1.git@$2" +} +compdef _pip pipigb + +# Install from GitHub pull request +function pipigp { + pip install "git+https://github.com/$1.git@refs/pull/$2/head" +} +compdef _pip pipigp From c189e8b40c2a9ed15850d5bb5a68e6789be5fc70 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Fri, 9 Dec 2022 18:10:04 +0000 Subject: [PATCH 71/77] feat(agnoster): add remote-tracking status to prompt (#7209) --- themes/agnoster.zsh-theme | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 5f4efe813..88854eccd 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -116,6 +116,17 @@ prompt_git() { prompt_segment green $CURRENT_FG fi + local ahead behind + ahead=$(git log --oneline @{upstream}.. 2>/dev/null) + behind=$(git log --oneline ..@{upstream} 2>/dev/null) + if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then + PL_BRANCH_CHAR=$'\u21c5' + elif [[ -n "$ahead" ]]; then + PL_BRANCH_CHAR=$'\u21b1' + elif [[ -n "$behind" ]]; then + PL_BRANCH_CHAR=$'\u21b0' + fi + if [[ -e "${repo_path}/BISECT_LOG" ]]; then mode=" " elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then From 82c0db41bcfd3fd97d6170dcb7575f98e38fc68d Mon Sep 17 00:00:00 2001 From: Basil Sh Date: Sat, 10 Dec 2022 00:11:16 +0600 Subject: [PATCH 72/77] docs(term_tab): rewrite README in markdown (#11381) --- plugins/term_tab/README | 16 ---------------- plugins/term_tab/README.md | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 plugins/term_tab/README create mode 100644 plugins/term_tab/README.md diff --git a/plugins/term_tab/README b/plugins/term_tab/README deleted file mode 100644 index 316062e73..000000000 --- a/plugins/term_tab/README +++ /dev/null @@ -1,16 +0,0 @@ - -term_tab - 'cwd' for all open zsh sessions -****************************************** - -What it does: -************* -This plugin allows to complete the 'cwd' of other Zsh sessions. Sounds -complicated but is rather simple. E.g. if you have three zsh sessions open, in -each session you are in a different folder, you can hit Ctrl+v in one session -to show you the current working directory of the other open zsh sessions. - -How it works: -************* -* It uses 'pidof zsh' to determine all zsh PIDs -* It reads procfs to get the current working directory of this session -* Everything is fed into zsh's completion magic diff --git a/plugins/term_tab/README.md b/plugins/term_tab/README.md new file mode 100644 index 000000000..7548fe6a8 --- /dev/null +++ b/plugins/term_tab/README.md @@ -0,0 +1,16 @@ +# term_tab plugin + +term_tab - `cwd` for all open zsh sessions + +## What it does: + +This plugin allows to complete the `cwd` of other Zsh sessions. Sounds +complicated but is rather simple. E.g. if you have three zsh sessions open, in +each session you are in a different folder, you can hit `Ctrl+V` in one session +to show you the current working directory of the other open zsh sessions. + +## How it works: + +* It uses `pidof zsh` to determine all zsh PIDs +* It reads procfs to get the current working directory of this session +* Everything is fed into zsh's completion magic From 29cf199b5d84eb4897f2e0e421a344174568eb9f Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Mon, 12 Dec 2022 03:18:29 -0500 Subject: [PATCH 73/77] docs(term_tab): plugin can only be used with linux and solaris (#11385) --- plugins/term_tab/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/term_tab/README.md b/plugins/term_tab/README.md index 7548fe6a8..59462a825 100644 --- a/plugins/term_tab/README.md +++ b/plugins/term_tab/README.md @@ -1,5 +1,7 @@ # term_tab plugin +This plugin only works for Solaris and linux. + term_tab - `cwd` for all open zsh sessions ## What it does: From 3705edf557922f286a5054523d6d7208e2ed6f5e Mon Sep 17 00:00:00 2001 From: kormosi <53222723+kormosi@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:47:10 +0100 Subject: [PATCH 74/77] feat(docker): add `drs` alias (#11393) --- plugins/docker/README.md | 1 + plugins/docker/docker.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 040a168d6..512b5d17c 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -58,6 +58,7 @@ file**, but be aware of the side effects: | drm | `docker container rm` | Remove the specified container(s) | | drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | | dst | `docker container start` | Start one or more stopped containers | +| drs | `docker container restart` | Restart one or more containers | dsta | `docker stop $(docker ps -q)` | Stop all running containers | | dstp | `docker container stop` | Stop one or more running containers | | dtop | `docker top` | Display the running processes of a container | diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 737803651..8684a9785 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -22,6 +22,7 @@ alias drit='docker container run -it' alias drm='docker container rm' alias 'drm!'='docker container rm -f' alias dst='docker container start' +alias drs='docker container restart' alias dsta='docker stop $(docker ps -q)' alias dstp='docker container stop' alias dtop='docker top' From 13082bb159361d1c0807eb7e5577f4c670cb0f88 Mon Sep 17 00:00:00 2001 From: Till Backhaus Date: Fri, 16 Dec 2022 12:46:34 +0100 Subject: [PATCH 75/77] feat(watson): add completion (#10886) Co-authored-by: Carlo Sala --- plugins/watson/README.md | 9 +++++++++ plugins/watson/_watson | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 plugins/watson/README.md create mode 100644 plugins/watson/_watson diff --git a/plugins/watson/README.md b/plugins/watson/README.md new file mode 100644 index 000000000..ef734ec63 --- /dev/null +++ b/plugins/watson/README.md @@ -0,0 +1,9 @@ +# Watson + +This plugin provides completion for [Watson](https://tailordev.github.io/Watson/). + +To use it add `watson` to the plugins array in your zshrc file. + +```zsh +plugins=(... watson) +``` diff --git a/plugins/watson/_watson b/plugins/watson/_watson new file mode 100644 index 000000000..0f599bd66 --- /dev/null +++ b/plugins/watson/_watson @@ -0,0 +1,34 @@ +#compdef watson + +_watson_completion() { + local -a completions + local -a completions_with_descriptions + local -a response + (( ! $+commands[watson] )) && return 1 + + response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _WATSON_COMPLETE=zsh_complete watson)}") + + for type key descr in ${response}; do + if [[ "$type" == "plain" ]]; then + if [[ "$descr" == "_" ]]; then + completions+=("$key") + else + completions_with_descriptions+=("$key":"$descr") + fi + elif [[ "$type" == "dir" ]]; then + _path_files -/ + elif [[ "$type" == "file" ]]; then + _path_files -f + fi + done + + if [ -n "$completions_with_descriptions" ]; then + _describe -V unsorted completions_with_descriptions -U + fi + + if [ -n "$completions" ]; then + compadd -U -V unsorted -a completions + fi +} + +compdef _watson_completion watson; From 2bc42d223cfe3e21aef06648fb971bd9fb00828e Mon Sep 17 00:00:00 2001 From: Renjith Date: Sat, 17 Dec 2022 22:23:48 +0530 Subject: [PATCH 76/77] feat(docker-compose): add `dcupdb` alias (#10235) --- plugins/docker-compose/README.md | 39 ++++++++++--------- .../docker-compose/docker-compose.plugin.zsh | 1 + 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index 13f3c2cea..bbcff2e0c 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -11,22 +11,23 @@ plugins=(... docker-compose) ## Aliases -| Alias | Command | Description | -|-----------|--------------------------------|------------------------------------------------------------------| -| dco | `docker-compose` | Docker-compose main command | -| dcb | `docker-compose build` | Build containers | -| dce | `docker-compose exec` | Execute command inside a container | -| dcps | `docker-compose ps` | List containers | -| dcrestart | `docker-compose restart` | Restart container | -| dcrm | `docker-compose rm` | Remove container | -| dcr | `docker-compose run` | Run a command in container | -| dcstop | `docker-compose stop` | Stop a container | -| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service | -| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers | -| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | -| dcdn | `docker-compose down` | Stop and remove containers | -| dcl | `docker-compose logs` | Show logs of container | -| dclf | `docker-compose logs -f` | Show logs and follow output | -| dcpull | `docker-compose pull` | Pull image of a service | -| dcstart | `docker-compose start` | Start a container | -| dck | `docker-compose kill` | Kills containers | +| Alias | Command | Description | +|-----------|--------------------------------|----------------------------------------------------------------------------------| +| dco | `docker-compose` | Docker-compose main command | +| dcb | `docker-compose build` | Build containers | +| dce | `docker-compose exec` | Execute command inside a container | +| dcps | `docker-compose ps` | List containers | +| dcrestart | `docker-compose restart` | Restart container | +| dcrm | `docker-compose rm` | Remove container | +| dcr | `docker-compose run` | Run a command in container | +| dcstop | `docker-compose stop` | Stop a container | +| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service | +| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers | +| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | +| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon | +| dcdn | `docker-compose down` | Stop and remove containers | +| dcl | `docker-compose logs` | Show logs of container | +| dclf | `docker-compose logs -f` | Show logs and follow output | +| dcpull | `docker-compose pull` | Pull image of a service | +| dcstart | `docker-compose start` | Start a container | +| dck | `docker-compose kill` | Kills containers | diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index b8a4b067d..7a8bf4a03 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -12,6 +12,7 @@ alias dcstop="$dccmd stop" alias dcup="$dccmd up" alias dcupb="$dccmd up --build" alias dcupd="$dccmd up -d" +alias dcupdb="$dccmd up -d --build" alias dcdn="$dccmd down" alias dcl="$dccmd logs" alias dclf="$dccmd logs -f" From 9c2d1af8afa02b5439e8ccc81a160e62e1e59617 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Tue, 20 Dec 2022 14:56:30 -0500 Subject: [PATCH 77/77] fix(doctl): actually load completions (#11402) --- plugins/doctl/doctl.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/doctl/doctl.plugin.zsh b/plugins/doctl/doctl.plugin.zsh index d23ed085c..7b3a384a9 100644 --- a/plugins/doctl/doctl.plugin.zsh +++ b/plugins/doctl/doctl.plugin.zsh @@ -4,6 +4,14 @@ # # Author: https://github.com/HalisCz -if [ $commands[doctl] ]; then - source <(doctl completion zsh) +if (( ! $+commands[doctl] )); then + return fi + +if [[ ! -f "$ZSH_CACHE_DIR/completions/_doctl" ]]; then + typeset -g -A _comps + autoload -Uz _doctl + _comps[doctl]=_doctl +fi + +doctl completion zsh >| "$ZSH_CACHE_DIR/completions/_doctl" &|