From 5b9de6a5304ad5f74ccb5862122a23b9ba06f6e3 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 19 Dec 2022 23:32:24 +0100 Subject: fix(init): remove duplicated check It was added due to #9039. See https://github.com/ohmyzsh/ohmyzsh/pull/11400#pullrequestreview-1223587420 --- oh-my-zsh.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index e94c2f417..98bda8c8b 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -57,9 +57,7 @@ mkdir -p "$ZSH_CACHE_DIR/completions" (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) # Check for updates on initial load... -if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then - source "$ZSH/tools/check_for_upgrade.sh" -fi +source "$ZSH/tools/check_for_upgrade.sh" # Initializes Oh My Zsh -- cgit v1.2.3-70-g09d2 From fe0dd8226d6f58ea98f9f84b279e6c3859993fb9 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 19 Dec 2022 23:33:55 +0100 Subject: fix(upgrade): do not upgrade if not called from tty Fixes #11390 --- .prettierrc | 4 ++++ tools/check_for_upgrade.sh | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..a8f5a14b0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 110, + "proseWrap": "always" +} diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 3a6bb6555..734714c94 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -21,9 +21,11 @@ zstyle -s ':omz:update' mode update_mode || { # Cancel update if: # - the automatic update is disabled. # - the current user doesn't have write permissions nor owns the $ZSH directory. +# - is not run from a tty # - git is unavailable on the system. if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ + || [[ ! -t 1 ]] \ || ! command git --version 2>&1 >/dev/null; then unset update_mode return -- cgit v1.2.3-70-g09d2 From 61dd3682e69aa990a8a3589c5c61ea2e1edf8312 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 17 Jan 2023 13:18:43 +0100 Subject: feat(nats)!: rename `nsc` plugin to `nats` --- plugins/nats/README.md | 14 ++++++++++++++ plugins/nats/nats.plugin.zsh | 23 +++++++++++++++++++++++ plugins/nsc/README.md | 11 ----------- plugins/nsc/nsc.plugin.zsh | 13 ------------- 4 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 plugins/nats/README.md create mode 100644 plugins/nats/nats.plugin.zsh delete mode 100644 plugins/nsc/README.md delete mode 100644 plugins/nsc/nsc.plugin.zsh diff --git a/plugins/nats/README.md b/plugins/nats/README.md new file mode 100644 index 000000000..0ea26fca1 --- /dev/null +++ b/plugins/nats/README.md @@ -0,0 +1,14 @@ +# NATS plugin + +This plugin adds completion for several tools from [NATS](https://nats.io/). + +- [`nsc`](https://github.com/nats-io/nsc) +- [`natscli`](https://github.com/nats-io/natscli) + +To use it, add `nats` to the plugins array in your zshrc file: + +```zsh +plugins=(... nats) +``` + +This plugin does not add any aliases. diff --git a/plugins/nats/nats.plugin.zsh b/plugins/nats/nats.plugin.zsh new file mode 100644 index 000000000..8b95b07c6 --- /dev/null +++ b/plugins/nats/nats.plugin.zsh @@ -0,0 +1,23 @@ +if (( $+commands[nsc] )); then + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `nsc`. Otherwise, compinit will have already done that. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_nsc" ]]; then + typeset -g -A _comps + autoload -Uz _nsc + _comps[nsc]=_nsc + fi + + nsc completion zsh >| "$ZSH_CACHE_DIR/completions/_nsc" &| +fi + +if (( $+commands[nats] )); then + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `nats`. Otherwise, compinit will have already done that. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_nats" ]]; then + typeset -g -A _comps + autoload -Uz _nats + _comps[nats]=_nats + fi + + nats --completion-script-zsh >| "$ZSH_CACHE_DIR/completions/_nats" &| +fi diff --git a/plugins/nsc/README.md b/plugins/nsc/README.md deleted file mode 100644 index ce0d2c15c..000000000 --- a/plugins/nsc/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# NSC plugin - -This plugin adds completion for the [NSC](https://github.com/nats-io/nsc). - -To use it, add `nsc` to the plugins array in your zshrc file: - -```zsh -plugins=(... nsc) -``` - -This plugin does not add any aliases. diff --git a/plugins/nsc/nsc.plugin.zsh b/plugins/nsc/nsc.plugin.zsh deleted file mode 100644 index daa599e8f..000000000 --- a/plugins/nsc/nsc.plugin.zsh +++ /dev/null @@ -1,13 +0,0 @@ -if (( ! $+commands[nsc] )); then - return -fi - -# If the completion file doesn't exist yet, we need to autoload it and -# bind it to `nsc`. Otherwise, compinit will have already done that. -if [[ ! -f "$ZSH_CACHE_DIR/completions/_nsc" ]]; then - typeset -g -A _comps - autoload -Uz _nsc - _comps[nsc]=_nsc -fi - -nsc completion zsh >| "$ZSH_CACHE_DIR/completions/_nsc" &| -- cgit v1.2.3-70-g09d2 From f1a800067f46fa990a11ea0055459560ce63a7ae Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 19 Jan 2023 12:20:44 +0100 Subject: fix(brew)!: rename `buf` alias to `bfu` BREAKING CHANGE: rename `buf` alias to `bfu` to avoid conflicts with protobuf tool --- plugins/brew/README.md | 28 ++++++++++++++-------------- plugins/brew/brew.plugin.zsh | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 4a42b3d74..d0c150237 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -17,20 +17,20 @@ defined for convenience. ## Aliases -| Alias | Command | Description | -| -------- | ------------------------------------- | ------------------------------------------------------------------- | -| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | -| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | -| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | -| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | -| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | -| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | -| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | -| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. | -| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | -| `bubu` | `bubo && bubc` | Do the last two operations above. | -| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). | -| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. | +| Alias | Command | Description | +| -------- | --------------------------------------- | ------------------------------------------------------------------- | +| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | +| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | +| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | +| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | +| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | +| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | +| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | +| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. | +| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | +| `bubu` | `bubo && bubc` | Do the last two operations above. | +| `bfu` | `brew upgrade --formula` | Upgrade only formulas (not casks). | +| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. | ## Completion diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 8275454a4..f6abe0875 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -35,7 +35,7 @@ alias bugbc='brew upgrade --greedy && brew cleanup' alias bubo='brew update && brew outdated' alias bubu='bubo && bubc' alias bubug='bubo && bugbc' -alias buf='brew upgrade --formula' +alias bfu='brew upgrade --formula' alias buz='brew uninstall --zap' function brews() { -- cgit v1.2.3-70-g09d2 From bf57b4ff3d53726a1317459b0f48853e90d7a6e4 Mon Sep 17 00:00:00 2001 From: Joan Marcè i Igual Date: Fri, 20 Jan 2023 19:45:14 +0100 Subject: feat(functions/take): make `.tgz` behave as `.tar.gz` (#11446) --- lib/functions.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index dfcc4d961..6e1faa6aa 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -56,7 +56,7 @@ function takegit() { } function take() { - if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then + if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then takeurl "$1" elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then takegit "$1" -- cgit v1.2.3-70-g09d2 From ba8777fc3013a3c682d8144586e16457cbe12586 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Sat, 21 Jan 2023 02:36:07 -0800 Subject: perf(fzf): speed up startup on debian (#11122) --- plugins/fzf/fzf.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 9c8dd8648..85a0bf270 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -60,8 +60,8 @@ function fzf_setup_using_base_dir() { function fzf_setup_using_debian() { - if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then - # Either not a debian based distro, or no fzf installed + if (( ! $+commands[dpkg] )); then + # Not a debian based distro return 1 fi @@ -72,11 +72,19 @@ function fzf_setup_using_debian() { case $PREFIX in *com.termux*) + if [[ ! -f "${PREFIX}/bin/fzf" ]]; then + # fzf not installed + return 1 + fi # Support Termux package completions="${PREFIX}/share/fzf/completion.zsh" key_bindings="${PREFIX}/share/fzf/key-bindings.zsh" ;; *) + if [[ ! -f /usr/bin/fzf ]]; then + # fzf not installed + return 1 + fi # Determine completion file path: first bullseye/sid, then buster/stretch completions="/usr/share/doc/fzf/examples/completion.zsh" [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf" -- cgit v1.2.3-70-g09d2 From a1c54e03f98b594a6fcc368c2c113d469ffaa368 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sun, 22 Jan 2023 23:36:57 +0100 Subject: feat(fzf): add `skip-dpkg` flag to avoid some regressions See https://github.com/ohmyzsh/ohmyzsh/pull/11122#issuecomment-1399607430 --- plugins/fzf/README.md | 9 +++++++++ plugins/fzf/fzf.plugin.zsh | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md index beedf4690..7e3e3e5b0 100644 --- a/plugins/fzf/README.md +++ b/plugins/fzf/README.md @@ -50,3 +50,12 @@ Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C): ```zsh DISABLE_FZF_KEY_BINDINGS="true" ``` + +### Skip `dpkg` loading + +If you have `dpkg` available in your `$PATH` but you don't want to load `fzf` from there, and facing some +issues, you can define this option before loading `oh-my-zsh` in order to skip that loading: + +```zsh +zstyle ':omz:plugins:fzf' skip-dpkg yes +``` diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 85a0bf270..c07d38493 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -60,8 +60,8 @@ function fzf_setup_using_base_dir() { function fzf_setup_using_debian() { - if (( ! $+commands[dpkg] )); then - # Not a debian based distro + if (( ! $+commands[dpkg] )) || zstyle -t ':omz:plugins:fzf' skip-dpkg; then + # Not a debian based distro return 1 fi -- cgit v1.2.3-70-g09d2 From 7de55844b26394688221b1cd12ef4053b3c7f6c7 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 23 Jan 2023 19:40:42 +0100 Subject: feat(mlh): add separate prompt symbol for root user (#11451) --- themes/mlh.zsh-theme | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme index baff3fb63..c059bf850 100644 --- a/themes/mlh.zsh-theme +++ b/themes/mlh.zsh-theme @@ -47,6 +47,10 @@ if [ -z "$MLH_SHELL_SYMBOL" ]; then MLH_SHELL_SYMBOL="$ " fi +if [ -z "$MLH_SHELL_SYMBOL_ROOT" ]; then + MLH_SHELL_SYMBOL_ROOT="# " +fi + # colors USER_COLOR="%F{001}" DEVICE_COLOR="%F{033}" @@ -83,7 +87,11 @@ exit_code() { } prompt_end() { - printf "\n$MLH_SHELL_SYMBOL" + if [ "$UID" -eq 0 ]; then + printf "\n$MLH_SHELL_SYMBOL_ROOT" + else + printf "\n$MLH_SHELL_SYMBOL" + fi } # Set git_prompt_info text -- cgit v1.2.3-70-g09d2 From 657ad0523d5a29e0bdc8af0cd63c23ac597406e8 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 25 Jan 2023 08:50:06 +0100 Subject: fix(theme-and-appearance): fix `diff` completion in macOS Closes #11416 Closes #11454 --- lib/theme-and-appearance.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 00947f72d..9b908bef0 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -41,7 +41,11 @@ fi # enable diff color if possible. if command diff --color /dev/null /dev/null &>/dev/null; then - alias diff='diff --color' + function color-diff { + diff --color $@ + } + alias diff="color-diff" + compdef _diff color-diff # compdef is already loaded by this point fi setopt auto_cd -- cgit v1.2.3-70-g09d2 From e55e3f0f56ab4df21eb33e19569c295e7e5e71a4 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 26 Jan 2023 20:45:48 +0100 Subject: fix(systemadmin): handle error for no IPv6 route in `geteip` (#11458) --- plugins/systemadmin/systemadmin.plugin.zsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 9b5159ff1..7ce62bac1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,7 +140,13 @@ function d0() { # gather external ip address function geteip() { curl -s -S -4 https://icanhazip.com - curl -s -S -6 https://icanhazip.com + + # handle case when there is no IPv6 external IP, which shows error + # curl: (7) Couldn't connect to server + curl -s -S -6 https://icanhazip.com 2>/dev/null + local ret=$? + (( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f" + return $ret } # determine local IP address(es) -- cgit v1.2.3-70-g09d2 From b0bffcaf865434711d98b63eddd0aa52be0fbeb1 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 27 Jan 2023 16:22:27 +0100 Subject: fix(fzf): fix check for true Debian-like in debian setup function (#11460) Check for `apt` and `apt-get` in debian setup function. Look for exact directory in debian-like setup function. Fixes #11459 --- plugins/fzf/README.md | 9 --------- plugins/fzf/fzf.plugin.zsh | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md index 7e3e3e5b0..beedf4690 100644 --- a/plugins/fzf/README.md +++ b/plugins/fzf/README.md @@ -50,12 +50,3 @@ Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C): ```zsh DISABLE_FZF_KEY_BINDINGS="true" ``` - -### Skip `dpkg` loading - -If you have `dpkg` available in your `$PATH` but you don't want to load `fzf` from there, and facing some -issues, you can define this option before loading `oh-my-zsh` in order to skip that loading: - -```zsh -zstyle ':omz:plugins:fzf' skip-dpkg yes -``` diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index c07d38493..7bb6667d0 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -60,7 +60,7 @@ function fzf_setup_using_base_dir() { function fzf_setup_using_debian() { - if (( ! $+commands[dpkg] )) || zstyle -t ':omz:plugins:fzf' skip-dpkg; then + if (( ! $+commands[apt] && ! $+commands[apt-get] )); then # Not a debian based distro return 1 fi @@ -81,7 +81,7 @@ function fzf_setup_using_debian() { key_bindings="${PREFIX}/share/fzf/key-bindings.zsh" ;; *) - if [[ ! -f /usr/bin/fzf ]]; then + if [[ ! -d /usr/share/doc/fzf/examples ]]; then # fzf not installed return 1 fi -- cgit v1.2.3-70-g09d2 From 39525e5ec36052a83fadd47f377a26d33df851bd Mon Sep 17 00:00:00 2001 From: Taehyun Hwang Date: Sun, 29 Jan 2023 02:45:23 +0900 Subject: feat(git): add `gpsupf` alias (#11268) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index d455e0eff..d5eaaa53f 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -89,6 +89,7 @@ plugins=(... git) | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | | ggu | git pull --rebase origin $(current_branch) | | gpsup | git push --set-upstream origin $(git_current_branch) | +| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease | | ghh | git help | | gignore | git update-index --assume-unchanged | | gignored | git ls-files -v \| grep "^[[:lower:]]" | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 7544ca440..fc2c08ccd 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -199,6 +199,7 @@ alias ggpush='git push origin "$(git_current_branch)"' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias gpsup='git push --set-upstream origin $(git_current_branch)' +alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease' alias ghh='git help' @@ -341,4 +342,4 @@ function grename() { fi } -unset git_version \ No newline at end of file +unset git_version -- cgit v1.2.3-70-g09d2 From b2313ec7493dc127c9712f20654579221d0bcce6 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 22 Oct 2020 21:57:23 -0400 Subject: feat(installer): respect and install in `$ZDOTDIR` if set (#9376) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9001 Fixes #10479 Closes #9376 Co-authored-by: Marc Cornellà --- tools/install.sh | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index a6538f9d7..4582ed03e 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -16,6 +16,9 @@ # ZSH=~/.zsh sh install.sh # # Respects the following environment variables: +# ZDOTDIR - path to Zsh dotfiles directory (default: unset). See [1][2] +# [1] https://zsh.sourceforge.io/Doc/Release/Parameters.html#index-ZDOTDIR +# [2] https://zsh.sourceforge.io/Doc/Release/Files.html#index-ZDOTDIR_002c-use-of # ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh) # REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh) # REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS) @@ -53,8 +56,17 @@ HOME="${HOME:-$(eval echo ~$USER)}" # Track if $ZSH was provided custom_zsh=${ZSH:+yes} -# Default settings +# Use $zdot to keep track of where the directory is for zsh dotfiles +# To check if $ZDOTDIR was provided, explicitly check for $ZDOTDIR +zdot="${ZDOTDIR:-$HOME}" + +# Default value for $ZSH +# a) if $ZDOTDIR is supplied: $ZDOTDIR/ohmyzsh +# b) otherwise, $HOME/.oh-my-zsh +ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" ZSH="${ZSH:-$HOME/.oh-my-zsh}" + +# Default settings REPO=${REPO:-ohmyzsh/ohmyzsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-master} @@ -311,11 +323,11 @@ setup_zshrc() { echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}" # Must use this exact name so uninstall.sh can find it - OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh - if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then + OLD_ZSHRC="$zdot/.zshrc.pre-oh-my-zsh" + if [ -f "$zdot/.zshrc" ] || [ -h "$zdot/.zshrc" ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ "$KEEP_ZSHRC" = yes ]; then - echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}" + echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then @@ -327,19 +339,22 @@ setup_zshrc() { fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" - echo "${FMT_YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ + echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \ "${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}" fi - echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}" - mv ~/.zshrc "$OLD_ZSHRC" + echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}" + mv "$zdot/.zshrc" "$OLD_ZSHRC" fi - echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${FMT_RESET}" + echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to $zdot/.zshrc.${FMT_RESET}" + + # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME + omz="$ZSH" + [ -z "$ZDOTDIR" ] || omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|") + omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|") - # Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file - omz=$(echo "$ZSH" | sed "s|^$HOME/|\$HOME/|") - sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp - mv -f ~/.zshrc-omztemp ~/.zshrc + sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" + mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc" echo } @@ -407,9 +422,9 @@ EOF # We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then - echo "$SHELL" > ~/.shell.pre-oh-my-zsh + echo "$SHELL" > "$zdot/.shell.pre-oh-my-zsh" else - grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh + grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > "$zdot/.shell.pre-oh-my-zsh" fi echo "Changing your shell to $zsh..." @@ -451,7 +466,7 @@ print_success() { printf '\n' printf '\n' printf "%s %s %s\n" "Before you scream ${FMT_BOLD}${FMT_YELLOW}Oh My Zsh!${FMT_RESET} look over the" \ - "$(fmt_code "$(fmt_link ".zshrc" "file://$HOME/.zshrc" --text)")" \ + "$(fmt_code "$(fmt_link ".zshrc" "file://$zdot/.zshrc" --text)")" \ "file to select plugins, themes, and options." printf '\n' printf '%s\n' "• Follow us on Twitter: $(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)" -- cgit v1.2.3-70-g09d2 From 27f31799df369ffdd825014bbbb853ad6a1ee520 Mon Sep 17 00:00:00 2001 From: Stoyan Dimov Date: Wed, 1 Feb 2023 10:51:31 +0100 Subject: feat(dotnet): add `dwt` alias (#11470) --- plugins/dotnet/README.md | 1 + plugins/dotnet/dotnet.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md index 87dfd8f8d..a15e80577 100644 --- a/plugins/dotnet/README.md +++ b/plugins/dotnet/README.md @@ -17,6 +17,7 @@ plugins=(... dotnet) | dt | dotnet test | Run unit tests using the test runner specified in a .NET project. | | dw | dotnet watch | Watch for source file changes and restart the dotnet command. | | dwr | dotnet watch run | Watch for source file changes and restart the `run` command. | +| dwt | dotnet watch test| Watch for source file changes and restart the `test` command. | | ds | dotnet sln | Modify Visual Studio solution files. | | da | dotnet add | Add a package or reference to a .NET project. | | dp | dotnet pack | Create a NuGet package. | diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index 8ea31cdbd..89d464670 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -26,6 +26,7 @@ alias dr='dotnet run' alias dt='dotnet test' alias dw='dotnet watch' alias dwr='dotnet watch run' +alias dwt='dotnet watch test' alias ds='dotnet sln' alias da='dotnet add' alias dp='dotnet pack' -- cgit v1.2.3-70-g09d2 From 5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 1 Feb 2023 21:19:55 +0100 Subject: fix(installer): don't use `$ZDOTDIR` in zshrc file if same as `$HOME` Fixes #11471 --- tools/install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 4582ed03e..3ea12f8d4 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -61,9 +61,9 @@ custom_zsh=${ZSH:+yes} zdot="${ZDOTDIR:-$HOME}" # Default value for $ZSH -# a) if $ZDOTDIR is supplied: $ZDOTDIR/ohmyzsh +# a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh # b) otherwise, $HOME/.oh-my-zsh -ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" +[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" ZSH="${ZSH:-$HOME/.oh-my-zsh}" # Default settings @@ -350,7 +350,9 @@ setup_zshrc() { # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME omz="$ZSH" - [ -z "$ZDOTDIR" ] || omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|") + if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then + omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|") + fi omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|") sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" -- cgit v1.2.3-70-g09d2 From 6c3cf658f6f341f7c716d6ff16714465cb651725 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 2 Feb 2023 08:49:08 +0100 Subject: fix(installer): automatically create ZDOTDIR path if it doesn't exist --- tools/install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index 3ea12f8d4..f4ef16a0c 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -523,6 +523,11 @@ EOF exit 1 fi + # Create ZDOTDIR folder structure if it doesn't exist + if [ -n "$ZDOTDIR" ]; then + mkdir -p "$ZDOTDIR" + fi + setup_ohmyzsh setup_zshrc setup_shell -- cgit v1.2.3-70-g09d2 From b256c12d2e96d0fbe63910df82b9709cca4b38df Mon Sep 17 00:00:00 2001 From: David Yang Date: Thu, 2 Feb 2023 16:03:41 +0800 Subject: docs(fasd): recommend fork over original fasd (#11474) --- plugins/fasd/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fasd/README.md b/plugins/fasd/README.md index a5c74e5b8..7c44ac84d 100644 --- a/plugins/fasd/README.md +++ b/plugins/fasd/README.md @@ -10,7 +10,7 @@ plugins=(... fasd) ## Installation -Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install) +Please find detailed installation guide [`here`](https://github.com/whjvenyl/fasd#install) ## Aliases -- cgit v1.2.3-70-g09d2 From ea4854dba3ef72e18df2c7cc79db2806d92322eb Mon Sep 17 00:00:00 2001 From: Hazael Sanchez Date: Thu, 2 Feb 2023 02:30:34 -0800 Subject: feat(directories): add config to skip aliases (#11469) Co-authored-by: Carlo Sala --- README.md | 10 ++++++++++ lib/directories.zsh | 2 ++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 1e4b7ff70..7f4a26cab 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,16 @@ If you have many functions that go well together, you can put them as a `XYZ.plu If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`. +### Remove directories aliases + +If you want to skip ohmyzsh default +[directories aliases](https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/directories.zsh) you can add the +following snippet to your `zshrc`, before loading `oh-my-zsh.sh` script: + +```zsh +zstyle ':omz:directories' aliases no +``` + ## Getting Updates By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**: diff --git a/lib/directories.zsh b/lib/directories.zsh index c62f56468..5aa1b3d5b 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -3,6 +3,8 @@ setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus +zstyle -T ':omz:directories' aliases || return + alias -g ...='../..' alias -g ....='../../..' alias -g .....='../../../..' -- cgit v1.2.3-70-g09d2 From f8bf8f0029a475831ebfba0799975ede20e08742 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 15 Dec 2022 23:06:06 +0100 Subject: fix(sudo): only call redisplay if zle is enabled Fixes #11322 --- plugins/sudo/sudo.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index 2a0b3bfc4..66b253fe7 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -96,7 +96,7 @@ sudo-command-line() { LBUFFER="${WHITESPACE}${LBUFFER}" # Redisplay edit buffer (compatibility with zsh-syntax-highlighting) - zle redisplay + zle && zle redisplay # only run redisplay if zle is enabled } } -- cgit v1.2.3-70-g09d2 From 9b91e8256011240cbf65ba65fbe55c5fd9dbae07 Mon Sep 17 00:00:00 2001 From: david Date: Sun, 5 Feb 2023 11:32:49 +0400 Subject: feat(extract): add `zpaq` support (#11478) --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 44f0b05a1..f67b53618 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -55,6 +55,7 @@ plugins=(... extract) | `xz` | LZMA2 archive | | `zip` | Zip archive | | `zst` | Zstandard file (zstd) | +| `zpaq` | Zpaq file | See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information regarding archive formats. diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 27b099c9e..64678fede 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 563d88c72..4c84ef883 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -73,6 +73,7 @@ EOF (*.zst) unzstd "$file" ;; (*.cab) cabextract -d "$extract_dir" "$file" ;; (*.cpio) cpio -idmvF "$file" ;; + (*.zpaq) zpaq x "$file" ;; (*) echo "extract: '$file' cannot be extracted" >&2 success=1 ;; -- cgit v1.2.3-70-g09d2 From d48cbb82b1a44d646c6b12b6bfb13c5fd366e1ae Mon Sep 17 00:00:00 2001 From: Unnit Metaliya Date: Mon, 6 Feb 2023 06:07:40 -0500 Subject: feat(git)!: add `force-if-includes` flag (#11481) Co-authored-by: Carlo Sala Closes #11388 BREAKING CHANGE: `gpf` and `gpsupf` now have the `--force-if-includes` flag if git version is greater than 2.30. It will make force pushes more safer. See https://stackoverflow.com/questions/65837109/when-should-i-use-git-push-force-if-includes --- plugins/git/README.md | 5 ++++- plugins/git/git.plugin.zsh | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index d5eaaa53f..cd018d435 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -89,7 +89,8 @@ plugins=(... git) | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | | ggu | git pull --rebase origin $(current_branch) | | gpsup | git push --set-upstream origin $(git_current_branch) | -| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease | +| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) | +| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) | | ghh | git help | | gignore | git update-index --assume-unchanged | | gignored | git ls-files -v \| grep "^[[:lower:]]" | @@ -120,6 +121,8 @@ plugins=(... git) | gp | git push | | gpd | git push --dry-run | | gpf | git push --force-with-lease | +| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) | +| gpf | git push --force-with-lease (git version < 2.30) | | gpf! | git push --force | | gpoat | git push origin --all && git push origin --tags | | gpr | git pull --rebase | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index fc2c08ccd..7541ccff2 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -199,7 +199,9 @@ alias ggpush='git push origin "$(git_current_branch)"' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias gpsup='git push --set-upstream origin $(git_current_branch)' -alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease' +is-at-least 2.30 "$git_version" \ + && alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \ + || alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease' alias ghh='git help' @@ -235,7 +237,9 @@ alias gma='git merge --abort' alias gp='git push' alias gpd='git push --dry-run' -alias gpf='git push --force-with-lease' +is-at-least 2.30 "$git_version" \ + && alias gpf='git push --force-with-lease --force-if-includes' \ + || alias gpf='git push --force-with-lease' alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' alias gpr='git pull --rebase' -- cgit v1.2.3-70-g09d2 From 3fd63fdf01344bb5f5f13a9c33eb0b7a72fe4771 Mon Sep 17 00:00:00 2001 From: Andrew Stone <61954919+adrwstone@users.noreply.github.com> Date: Mon, 6 Feb 2023 07:39:37 -0330 Subject: feat(zsh-interactive-cd): sync version with upstream (#11024) --- plugins/zsh-interactive-cd/LICENSE | 375 +++++++++++++++++++++ plugins/zsh-interactive-cd/README.md | 22 +- plugins/zsh-interactive-cd/demo.gif | Bin 0 -> 1497944 bytes .../zsh-interactive-cd.plugin.zsh | 54 ++- 4 files changed, 425 insertions(+), 26 deletions(-) create mode 100644 plugins/zsh-interactive-cd/LICENSE create mode 100644 plugins/zsh-interactive-cd/demo.gif diff --git a/plugins/zsh-interactive-cd/LICENSE b/plugins/zsh-interactive-cd/LICENSE new file mode 100644 index 000000000..40b3f8d7a --- /dev/null +++ b/plugins/zsh-interactive-cd/LICENSE @@ -0,0 +1,375 @@ +Copyright 2017-2018 Henry Chang + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/plugins/zsh-interactive-cd/README.md b/plugins/zsh-interactive-cd/README.md index c8337fbc8..4bffbf04a 100644 --- a/plugins/zsh-interactive-cd/README.md +++ b/plugins/zsh-interactive-cd/README.md @@ -1,23 +1,15 @@ # zsh-interactive-cd -This plugin adds a fish-like interactive tab completion for the `cd` command. +## Demo -To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file: -```zsh -plugins=(... zsh-interactive-cd) -``` +![demo](demo.gif) -![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif) +## Installation -## Usage - -Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage. +1. Install [fzf](https://github.com/junegunn/fzf) by following its [installation instruction](https://github.com/junegunn/fzf#installation). -## Requirements +2. Source `zsh-interactive-cd.plugin.zsh` in `.zshrc`. -This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following -its [installation instructions](https://github.com/junegunn/fzf#installation). - -## Author +## Usage -[Henry Chang](https://github.com/changyuheng) +Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage. diff --git a/plugins/zsh-interactive-cd/demo.gif b/plugins/zsh-interactive-cd/demo.gif new file mode 100644 index 000000000..3568ecf95 Binary files /dev/null and b/plugins/zsh-interactive-cd/demo.gif differ diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh index b0520c239..0ae9d50a7 100644 --- a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh +++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh @@ -1,4 +1,10 @@ -# Copyright (c) 2017 Henry Chang +#!/usr/bin/env zsh +# +# Copyright 2017-2018 Henry Chang +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. __zic_fzf_prog() { [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \ @@ -17,7 +23,7 @@ __zic_matched_subdir_list() { length=0 fi find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \ - | cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do + | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' | while read -r line; do if [[ "${line[1]}" == "." ]]; then continue fi @@ -32,13 +38,19 @@ __zic_matched_subdir_list() { seg=$(basename -- "$1") starts_with_dir=$( \ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \ - 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \ + 2>/dev/null | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' \ | while read -r line; do if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then continue fi - if [[ "$line" == "$seg"* ]]; then - echo "$line" + if [ "$zic_case_insensitive" = "true" ]; then + if [[ "$line:u" == "$seg:u"* ]]; then + echo "$line" + fi + else + if [[ "$line" == "$seg"* ]]; then + echo "$line" + fi fi done ) @@ -46,19 +58,36 @@ __zic_matched_subdir_list() { echo "$starts_with_dir" else find -L "$dir" -mindepth 1 -maxdepth 1 -type d \ - 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \ + 2>/dev/null | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' \ | while read -r line; do if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then continue fi - if [[ "$line" == *"$seg"* ]]; then - echo "$line" + if [ "$zic_case_insensitive" = "true" ]; then + if [[ "$line:u" == *"$seg:u"* ]]; then + echo "$line" + fi + else + if [[ "$line" == *"$seg"* ]]; then + echo "$line" + fi fi done fi fi } +__zic_fzf_bindings() { + autoload is-at-least + fzf=$(__zic_fzf_prog) + + if $(is-at-least '0.21.0' $(${=fzf} --version)); then + echo 'shift-tab:up,tab:down,bspace:backward-delete-char/eof' + else + echo 'shift-tab:up,tab:down' + fi +} + _zic_list_generator() { __zic_matched_subdir_list "${(Q)@[-1]}" | sort } @@ -75,6 +104,7 @@ _zic_complete() { fi fzf=$(__zic_fzf_prog) + fzf_bindings=$(__zic_fzf_bindings) if [ $(echo $l | wc -l) -eq 1 ]; then matches=${(q)l} @@ -82,7 +112,7 @@ _zic_complete() { matches=$(echo $l \ | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \ --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \ - --bind 'shift-tab:up,tab:down'" ${=fzf} \ + --bind '${fzf_bindings}'" ${=fzf} \ | while read -r item; do echo -n "${(q)item} " done) @@ -144,5 +174,7 @@ zic-completion() { } zle -N zic-completion -bindkey -M emacs '^I' zic-completion -bindkey -M viins '^I' zic-completion +if [ -z $zic_custom_binding ]; then + zic_custom_binding='^I' +fi +bindkey "${zic_custom_binding}" zic-completion -- cgit v1.2.3-70-g09d2 From 379fe0fe131cff7a480f7975b32b0ea6fc7c2370 Mon Sep 17 00:00:00 2001 From: Julien Rottenberg Date: Tue, 7 Feb 2023 03:33:59 -0800 Subject: feat(azure): add `azure` plugin (#8848) Co-authored-by: hagridaaron Co-authored-by: Terry Closes #8847 --- lib/prompt_info_functions.zsh | 1 + plugins/azure/README.md | 49 ++++++++++++++++++++++++++++++++++ plugins/azure/azure.plugin.zsh | 60 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 plugins/azure/README.md create mode 100644 plugins/azure/azure.plugin.zsh diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index e5535848b..3dc9b6d10 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -18,6 +18,7 @@ function chruby_prompt_info \ vi_mode_prompt_info \ virtualenv_prompt_info \ jenv_prompt_info \ + azure_prompt_info \ tf_prompt_info \ { return 1 diff --git a/plugins/azure/README.md b/plugins/azure/README.md new file mode 100644 index 000000000..f39930851 --- /dev/null +++ b/plugins/azure/README.md @@ -0,0 +1,49 @@ +# azure + +This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/) +and a few utilities to manage azure subscriptions and display them in the prompt. + +To use it, add `azure` to the plugins array in your zshrc file. + +```zsh +plugins=(... azure) +``` + +## Plugin commands + + +* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`). + Used to provide completion for the `azss` function. + +* `azgs`: gets the current value of `$azure_subscription`. + +* `azss []`: sets the `$azure_subscription`. + + +NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing + +## Theme + +The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays +the current `$azure_subscription`. It uses two variables to control how that is shown: + +- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to ``. + + +``` +RPROMPT='$(azure_prompt_info)' +``` + +## Develop + +On ubuntu get a working environment with : + +` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash` + +``` +apt install -y curl jq zsh git vim +sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +curl -sL https://aka.ms/InstallAzureCLIDeb | bash +``` \ No newline at end of file diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh new file mode 100644 index 000000000..7bb173a5c --- /dev/null +++ b/plugins/azure/azure.plugin.zsh @@ -0,0 +1,60 @@ +# AZ Get Subscritions +function azgs() { + az account show --output tsv --query 'name' 2>/dev/null +} + +# AZ Subscription Selection +alias azss="az account set --subscription" + + +function az_subscriptions() { + az account list --all --output tsv --query '[*].name' 2> /dev/null +} + +function _az_subscriptions() { + reply=($(az_subscriptions)) +} +compctl -K _az_subscriptions azss + +# Azure prompt +function azure_prompt_info() { + [[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}" ]] && return + # azgs is too expensive, if we have jq, we enable the prompt + (( $+commands[jq] )) || return 1 + azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}) + echo "${ZSH_THEME_AZURE_PREFIX:=}" +} + + +# Load az completions +function _az-homebrew-installed() { + # check if Homebrew is installed + (( $+commands[brew] )) || return 1 + + # speculatively check default brew prefix + if [ -h /usr/local/opt/az ]; then + _brew_prefix=/usr/local/opt/az + else + # ok, it is not in the default prefix + # this call to brew is expensive (about 400 ms), so at least let's make it only once + _brew_prefix=$(brew --prefix azure-cli) + fi +} + + +# get az.completion.sh location from $PATH +_az_zsh_completer_path="$commands[az_zsh_completer.sh]" + +# otherwise check common locations +if [[ -z $_az_zsh_completer_path ]]; then + # Homebrew + if _az-homebrew-installed; then + _az_zsh_completer_path=$_brew_prefix/libexec/bin/az.completion.sh + # Linux + else + _az_zsh_completer_path=/etc/bash_completion.d/azure-cli + fi +fi + +[[ -r $_az_zsh_completer_path ]] && source $_az_zsh_completer_path +unset _az_zsh_completer_path _brew_prefix -- cgit v1.2.3-70-g09d2 From 87f1941d27df2e9a3390e5d1cddf6c264ba7311d Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 7 Feb 2023 16:17:07 +0100 Subject: docs(git): remove duplicated line --- plugins/git/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index cd018d435..1c3f8acf0 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -120,7 +120,6 @@ plugins=(... git) | gma | git merge --abort | | gp | git push | | gpd | git push --dry-run | -| gpf | git push --force-with-lease | | gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) | | gpf | git push --force-with-lease (git version < 2.30) | | gpf! | git push --force | -- cgit v1.2.3-70-g09d2 From 45571bfa03934359a49f7043cbcf50abccdf448c Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 8 Feb 2023 11:35:48 +0100 Subject: fix(git): `gpristine` requires two `--force` flags Fixes #11483 --- 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 7541ccff2..70e6b4439 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -104,7 +104,7 @@ compdef _git gccd=git-clone alias gcl='git clone --recurse-submodules' alias gclean='git clean --interactive -d' -alias gpristine='git reset --hard && git clean --force -dx' +alias gpristine='git reset --hard && git clean --force -dfx' alias gcm='git checkout $(git_main_branch)' alias gcd='git checkout $(git_develop_branch)' alias gcmsg='git commit --message' -- cgit v1.2.3-70-g09d2 From 0e9e5360c400cda5a80c9394583b9acbf7cfe711 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 9 Feb 2023 12:24:39 +0100 Subject: feat(gradle): update completion from upstream (#11485) --- plugins/gradle/_gradle | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle index 770723d85..1da5aebee 100644 --- a/plugins/gradle/_gradle +++ b/plugins/gradle/_gradle @@ -1,4 +1,3 @@ -#compdef gradle gradlew gw # # Taken from https://github.com/gradle/gradle-completion # Copyright (c) 2017 Eric Wendelin @@ -22,6 +21,8 @@ # SOFTWARE. # Terms +#compdef gradle gradlew gw + __gradle-set-project-root-dir() { local dir=`pwd` project_root_dir=`pwd` @@ -96,7 +97,7 @@ __gradle-generate-script-cache() { zle -R "Generating Gradle build script cache" # Cache all Gradle scripts local -a gradle_build_scripts - gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") ) + gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") ) printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name fi } @@ -116,9 +117,9 @@ __gradle-generate-tasks-cache() { # Reuse Gradle Daemon if IDLE but don't start a new one. local gradle_tasks_output if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then - gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)" + gradle_tasks_output="$($gradle_cmd --daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)" else - gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)" + gradle_tasks_output="$($gradle_cmd --no-daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)" fi local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line local -a match @@ -180,7 +181,7 @@ __gradle_tasks() { local cached_checksum="$(cat $cache_dir/$cache_name.md5)" local -a cached_tasks if [[ -z $cur ]]; then - cached_tasks=(${(f)"$(cat $cache_dir/$cached_checksum)"}) + cached_tasks=(${(f)"$(grep -v "^\\\:" $cache_dir/$cached_checksum)"}) else cached_tasks=(${(f)"$(grep "^${cur//:/\\\\:}" $cache_dir/$cached_checksum)"}) fi @@ -191,7 +192,7 @@ __gradle_tasks() { # Regenerate tasks cache in the background if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum || $(wc -c < $cache_dir/$gradle_files_checksum) -le 1 ]]; then - $(__gradle-generate-tasks-cache 1>&2 2>/dev/null &) + $(__gradle-generate-tasks-cache &> /dev/null &) fi else _describe 'built-in tasks' '( @@ -262,7 +263,10 @@ __gradle_subcommand() { {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \ {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \ {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle' \ + '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \ + '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \ '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \ + '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \ '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \ '--continue[Continues task execution after a task failure.]' \ '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \ @@ -276,6 +280,7 @@ __gradle_subcommand() { '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \ '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:enable parallel build:(true false)' \ '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \ '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \ '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \ '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \ @@ -314,6 +319,7 @@ __gradle_subcommand() { '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \ '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \ '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \ + '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \ '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \ {-x,--exclude-task}'[Specify a task to be excluded from execution.]' && ret=0 ;; @@ -347,6 +353,9 @@ _gradle() { {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \ {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \ {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle:->argument-expected' \ + '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \ + '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \ + '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \ '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \ '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \ '--continue[Continues task execution after a task failure.]' \ @@ -361,6 +370,7 @@ _gradle() { '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \ '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:(true false)' \ '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \ '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \ '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \ '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \ @@ -404,6 +414,7 @@ _gradle() { '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \ '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \ '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \ + '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \ {-x,--exclude-task}'[Specify a task to be excluded from execution.]' \ '(-)*:: :->task-or-option' && ret=0 -- cgit v1.2.3-70-g09d2 From 041c35ffc8cd97dd6327f44e35fa777af6f8e845 Mon Sep 17 00:00:00 2001 From: Samyak Sarnayak Date: Thu, 9 Feb 2023 16:57:41 +0530 Subject: feat(amuse): add virtualenv support (#8987) Fixes #7766 Closes #8814 --- themes/amuse.zsh-theme | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme index 3f7ec0bc5..d787fdaa4 100644 --- a/themes/amuse.zsh-theme +++ b/themes/amuse.zsh-theme @@ -11,8 +11,14 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg_bold[red]%}‹" ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}" PROMPT=' -%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} +%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)$(virtualenv_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} $ ' RPROMPT='$(ruby_prompt_info)' +VIRTUAL_ENV_DISABLE_PROMPT=0 +ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=" %{$fg[green]%}🐍" +ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_VIRTUALENV_PREFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX +ZSH_THEME_VIRTUALENV_SUFFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX + -- cgit v1.2.3-70-g09d2 From f9104d155f618f2d6f5e13af648c81a5d036a592 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Sat, 11 Feb 2023 20:54:20 +0100 Subject: fix(gradle): move compdef line (#11488) --- plugins/gradle/_gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle index 1da5aebee..f8df928b4 100644 --- a/plugins/gradle/_gradle +++ b/plugins/gradle/_gradle @@ -1,3 +1,6 @@ +#compdef gradle gradlew gw +# THE LINE ABOVE MUST BE THE FIRST LINE OF THIS FILE IN ORDER FOR COMPLETION TO WORK + # # Taken from https://github.com/gradle/gradle-completion # Copyright (c) 2017 Eric Wendelin @@ -21,8 +24,6 @@ # SOFTWARE. # Terms -#compdef gradle gradlew gw - __gradle-set-project-root-dir() { local dir=`pwd` project_root_dir=`pwd` -- cgit v1.2.3-70-g09d2 From 3e1c0d51cb66cf02357b25f514d55a3de8197647 Mon Sep 17 00:00:00 2001 From: GrandZhuo Date: Sun, 12 Feb 2023 16:53:04 +0800 Subject: fix(fzf): installation dir for brew M1 (#11490) --- 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 7bb6667d0..b253a23d2 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -9,7 +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" + "/opt/homebrew/opt/fzf" "/usr/share/fzf" "/usr/local/share/examples/fzf" ) -- cgit v1.2.3-70-g09d2 From ed407466b8ae3c12c2f03da004d721618e64fd49 Mon Sep 17 00:00:00 2001 From: Ruben van Erk Date: Sun, 12 Feb 2023 16:05:06 +0100 Subject: docs(lando): php support (#11491) --- plugins/lando/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/lando/README.md b/plugins/lando/README.md index 928a42bca..6daeae4e4 100644 --- a/plugins/lando/README.md +++ b/plugins/lando/README.md @@ -17,6 +17,7 @@ plugins=(... lando) | `drush` | `lando drush` | | `gulp` | `lando gulp` | | `npm` | `lando npm` | +| `php` | `lando php` | | `wp` | `lando wp` | | `yarn` | `lando yarn` | -- cgit v1.2.3-70-g09d2 From 416560c9bf0c03afe6f576ab9e420256843bfb8b Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Sun, 12 Feb 2023 11:46:25 -0500 Subject: docs(lib/directories): comment how to disable alias (#11489) --- lib/directories.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/directories.zsh b/lib/directories.zsh index 5aa1b3d5b..091140626 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -3,6 +3,11 @@ setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus +# add (uncommented): +# zstyle ':omz:directories' aliases no +# to your `zshrc` before loading `oh-my-zsh.sh` +# to disable the following aliases and functions + zstyle -T ':omz:directories' aliases || return alias -g ...='../..' -- cgit v1.2.3-70-g09d2 From 69b5737daf0448ad7e6686174638be74f86afdec Mon Sep 17 00:00:00 2001 From: shelfofclub Date: Tue, 14 Feb 2023 20:44:23 +0800 Subject: fix(af-magic): fix python venv checking logic (#11495) --- themes/af-magic.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index 2ef9b02d7..1b629e43a 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -10,7 +10,7 @@ function afmagic_dashes { # if there is a python virtual environment and it is displayed in # the prompt, account for it when returning the number of dashes - if [[ -n "$python_env" && "$PS1" = \(* ]]; then + if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then echo $(( COLUMNS - ${#python_env} - 3 )) else echo $COLUMNS -- cgit v1.2.3-70-g09d2 From 574669da6b71462c1f92c75ad75f66476b92974c Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Sat, 11 Feb 2023 10:46:31 -0500 Subject: fix(correction)!: remove aliases for non standard commands BREAKING CHANGE: This commit removes aliases for some commands that previously were not being autocorrected. If you are using autocorrection, please check it. --- lib/correction.zsh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/correction.zsh b/lib/correction.zsh index 4259d3418..ba9664fcb 100644 --- a/lib/correction.zsh +++ b/lib/correction.zsh @@ -1,13 +1,8 @@ if [[ "$ENABLE_CORRECTION" == "true" ]]; then alias cp='nocorrect cp' - alias ebuild='nocorrect ebuild' - alias gist='nocorrect gist' - alias heroku='nocorrect heroku' - alias hpodder='nocorrect hpodder' alias man='nocorrect man' alias mkdir='nocorrect mkdir' alias mv='nocorrect mv' - alias mysql='nocorrect mysql' alias sudo='nocorrect sudo' alias su='nocorrect su' -- cgit v1.2.3-70-g09d2 From 8a68bf67720a6a5442ae947d10d74b1dd3558d91 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 16 Feb 2023 12:54:23 +0100 Subject: fix(theme-and-appearance): test color ls with $ZSH directory Fixes #11500 --- lib/theme-and-appearance.zsh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 9b908bef0..c83f58c7b 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -7,32 +7,37 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" # TODO organise this chaotic logic if [[ "$DISABLE_LS_COLORS" != "true" ]]; then + if [[ -d "$ZSH" ]]; then + _test_dir="$ZSH" + else + _test_dir="." + fi # Find the option for using colors in ls, depending on the version if [[ "$OSTYPE" == netbsd* ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d . &>/dev/null && alias ls='gls --color=tty' + gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' elif [[ "$OSTYPE" == openbsd* ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing # coreutils, so prefer it to "gls". - gls --color -d . &>/dev/null && alias ls='gls --color=tty' - colorls -G -d . &>/dev/null && alias ls='colorls -G' + gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' + colorls -G -d "$_test_dir" &>/dev/null && alias ls='colorls -G' elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then # this is a good alias, it works by default just using $LSCOLORS - ls -G . &>/dev/null && alias ls='ls -G' + ls -G "$_test_dir" &>/dev/null && alias ls='ls -G' # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) # otherwise, gls will use the default color scheme which is ugly af - [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty' + [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. if [[ -z "$LS_COLORS" ]]; then (( $+commands[dircolors] )) && eval "$(dircolors -b)" fi - ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' } + ls --color -d "$_test_dir" &>/dev/null && alias ls='ls --color=tty' || { ls -G "$_test_dir" &>/dev/null && alias ls='ls -G' } # Take advantage of $LS_COLORS for completion as well. zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -- cgit v1.2.3-70-g09d2 From 25368f9a65e805a961884ce70206c907218fc741 Mon Sep 17 00:00:00 2001 From: Juan Antonio Ramírez Date: Fri, 17 Feb 2023 03:09:00 -0400 Subject: fix(gcloud): add location of latest snap install (#11502) Latest snap installs gcloud at /snap/google-cloud-cli, so add that to the list of possible locations. --- plugins/gcloud/gcloud.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh index 9be9d68aa..30f1dba8f 100644 --- a/plugins/gcloud/gcloud.plugin.zsh +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -10,6 +10,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/usr/share/google-cloud-sdk" "/snap/google-cloud-sdk/current" + "/snap/google-cloud-cli/current" "/usr/lib/google-cloud-sdk" "/usr/lib64/google-cloud-sdk" "/opt/google-cloud-sdk" -- cgit v1.2.3-70-g09d2 From aace3a6144a859d877927746a865de820e5af838 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 17 Feb 2023 16:42:59 +0100 Subject: chore: add `.idea` directory to `.gitignore` --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 71ae444e5..10bd4bebc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ log/ .DS_Store # editor configs -.vscode \ No newline at end of file +.vscode +.idea -- cgit v1.2.3-70-g09d2 From cc73a929f637899407d7a17648f89c63b71cc1ff Mon Sep 17 00:00:00 2001 From: guenthgr Date: Fri, 17 Feb 2023 17:29:10 +0100 Subject: feat(git): add `gpod` alias Closes #11501 --- 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 1c3f8acf0..9972a6d8d 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -124,6 +124,7 @@ plugins=(... git) | gpf | git push --force-with-lease (git version < 2.30) | | gpf! | git push --force | | gpoat | git push origin --all && git push origin --tags | +| gpod | git push origin --delete | | gpr | git pull --rebase | | gpu | git push upstream | | gpv | git push --verbose | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 70e6b4439..b016d80db 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -242,6 +242,7 @@ is-at-least 2.30 "$git_version" \ || alias gpf='git push --force-with-lease' alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' +alias gpod='git push origin --delete' alias gpr='git pull --rebase' alias gpu='git push upstream' alias gpv='git push --verbose' -- cgit v1.2.3-70-g09d2 From 8c808da23c9bafdc9d4b7b73934d6621d3a1f83e Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Mon, 20 Feb 2023 15:35:58 +0100 Subject: feat(git): add aliases for gone branches (#9250) Closes #8457 Closes #9973 --- plugins/git/README.md | 3 +++ plugins/git/git.plugin.zsh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 9972a6d8d..0895ce39c 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -25,6 +25,9 @@ plugins=(... git) | gbd | git branch --delete | | gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch --delete 2>/dev/null | | gbD | git branch --delete --force | +| gbg | git branch -vv | grep ": gone\]" | +| gbgd | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs git branch -d | +| gbgD | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs git branch -D | | gbl | git blame -b -w | | gbnm | git branch --no-merged | | gbr | git branch --remote | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index b016d80db..ed17436e8 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -73,6 +73,9 @@ alias gba='git branch --all' alias gbd='git branch --delete' alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null' alias gbD='git branch --delete --force' +alias gbg='git branch -vv | grep ": gone\]"' +alias gbgd='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -d' +alias gbgD='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' -- cgit v1.2.3-70-g09d2 From c50bac7b42e7d24dd9ef314fa9bf17859e4218ed Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 21 Feb 2023 11:19:56 +0100 Subject: fix(terraform): go back to zsh custom completion Revert fcbfdf42de702d55174fe2b19142ba232289671e --- plugins/terraform/_terraform | 411 +++++++++++++++++++++++++++++++++ plugins/terraform/terraform.plugin.zsh | 5 - 2 files changed, 411 insertions(+), 5 deletions(-) create mode 100644 plugins/terraform/_terraform diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform new file mode 100644 index 000000000..625834563 --- /dev/null +++ b/plugins/terraform/_terraform @@ -0,0 +1,411 @@ +#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 eaa1e2e81..d9e39e6ac 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -16,8 +16,3 @@ 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 -- cgit v1.2.3-70-g09d2 From 9f9d3b7d247b3c3e21542abaaf107e3d15aac1a5 Mon Sep 17 00:00:00 2001 From: rohitbahekar <57762527+rohitbahekar@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:53:04 +0530 Subject: feat(terraform): add `tfc` alias (#10815) --- plugins/terraform/README.md | 1 + plugins/terraform/terraform.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index 59c6e7f2a..c19f2ad1c 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -19,6 +19,7 @@ plugins=(... terraform) | ----- | -------------------- | | `tf` | `terraform` | | `tfa` | `terraform apply` | +| `tfc` | `terraform console` | | `tfd` | `terraform destroy` | | `tff` | `terraform fmt` | | `tfi` | `terraform init` | diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index d9e39e6ac..7006f204b 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -10,6 +10,7 @@ function tf_prompt_info() { alias tf='terraform' alias tfa='terraform apply' +alias tfc='terraform console' alias tfd='terraform destroy' alias tff='terraform fmt' alias tfi='terraform init' -- cgit v1.2.3-70-g09d2 From a4f08ad238dba23a68df2a89b8fd47b8a9d26b0e Mon Sep 17 00:00:00 2001 From: Filippo Bonazzi Date: Wed, 22 Feb 2023 10:16:28 +0100 Subject: feat(extract): support `obscpio` format (#11511) Co-authored-by: Carlo Sala --- plugins/extract/README.md | 15 ++++++++------- plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index f67b53618..ac4a8e197 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -1,10 +1,10 @@ # extract plugin -This plugin defines a function called `extract` that extracts the archive file -you pass it, and it supports a wide variety of archive filetypes. +This plugin defines a function called `extract` that extracts the archive file you pass it, and it supports a +wide variety of archive filetypes. -This way you don't have to know what specific command extracts a file, you just -do `extract ` and the function takes care of the rest. +This way you don't have to know what specific command extracts a file, you just do `extract ` and +the function takes care of the rest. To use it, add `extract` to the plugins array in your zshrc file: @@ -15,7 +15,7 @@ plugins=(... extract) ## Supported file extensions | Extension | Description | -|:------------------|:-------------------------------------| +| :---------------- | :----------------------------------- | | `7z` | 7zip file | | `Z` | Z archive (LZW) | | `apk` | Android app file | @@ -32,6 +32,7 @@ plugins=(... extract) | `lrz` | LRZ archive | | `lz4` | LZ4 archive | | `lzma` | LZMA archive | +| `obscpio` | cpio archive used on OBS | | `rar` | WinRAR archive | | `rpm` | RPM package | | `sublime-package` | Sublime Text package | @@ -57,5 +58,5 @@ plugins=(... extract) | `zst` | Zstandard file (zstd) | | `zpaq` | Zpaq file | -See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for -more information regarding archive formats. +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information +regarding archive formats. diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 64678fede..56b17058f 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 4c84ef883..7b7a2fa4f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -72,7 +72,7 @@ EOF builtin cd -q ..; command rm *.tar.* debian-binary ;; (*.zst) unzstd "$file" ;; (*.cab) cabextract -d "$extract_dir" "$file" ;; - (*.cpio) cpio -idmvF "$file" ;; + (*.cpio|*.obscpio) cpio -idmvF "$file" ;; (*.zpaq) zpaq x "$file" ;; (*) echo "extract: '$file' cannot be extracted" >&2 -- cgit v1.2.3-70-g09d2 From 221eb9b90ab4d03b6f00e62f31e979459e08e7ca Mon Sep 17 00:00:00 2001 From: 冯不游 <71683364+mefengl@users.noreply.github.com> Date: Tue, 21 Feb 2023 03:07:45 +0800 Subject: feat(marktext): add plugin Closes #11507 --- plugins/marktext/README.md | 17 +++++++++++++++++ plugins/marktext/marktext.plugin.zsh | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100644 plugins/marktext/README.md create mode 100644 plugins/marktext/marktext.plugin.zsh diff --git a/plugins/marktext/README.md b/plugins/marktext/README.md new file mode 100644 index 000000000..71d287451 --- /dev/null +++ b/plugins/marktext/README.md @@ -0,0 +1,17 @@ +## marktext + +Plugin for MarkText, a previewer for Markdown files on Mac OS X + +### Requirements + + * [MarkText](https://github.com/marktext/marktext) + +### Usage + + * If `marktext` is called without an argument, open MarkText + + * If `marktext` is passed a file, open it in MarkText + +### Credits + + * just copied from plugins/marked2, all credits to marked2 plugin author diff --git a/plugins/marktext/marktext.plugin.zsh b/plugins/marktext/marktext.plugin.zsh new file mode 100644 index 000000000..1da85bcca --- /dev/null +++ b/plugins/marktext/marktext.plugin.zsh @@ -0,0 +1,7 @@ +# +# If marktext is called without an argument, open MarkText +# If marktext is passed a file, open it in MarkText +# +function marktext() { + open -a "MarkText.app" "$1" +} -- cgit v1.2.3-70-g09d2 From a24e91908adb25dfc222e6a6f6431e2fbc890545 Mon Sep 17 00:00:00 2001 From: 冯不游 <71683364+mefengl@users.noreply.github.com> Date: Wed, 22 Feb 2023 18:26:30 +0800 Subject: feat(marked): remove unnecessary code --- plugins/marked2/marked2.plugin.zsh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/marked2/marked2.plugin.zsh b/plugins/marked2/marked2.plugin.zsh index 56863ade5..45f4b65c1 100644 --- a/plugins/marked2/marked2.plugin.zsh +++ b/plugins/marked2/marked2.plugin.zsh @@ -3,10 +3,5 @@ # If marked is passed a file, open it in Marked # function marked() { - if [ "$1" ] - then - open -a "marked 2.app" "$1" - else - open -a "marked 2.app" - fi + open -a "marked 2.app" "$1" } -- cgit v1.2.3-70-g09d2 From aca048814b2462501ab82938ff2473661182fffb Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 22 Feb 2023 15:35:12 +0100 Subject: fix(theme-and-appearance): avoid infinite recursion --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index c83f58c7b..1b64b51d4 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -47,7 +47,7 @@ fi # enable diff color if possible. if command diff --color /dev/null /dev/null &>/dev/null; then function color-diff { - diff --color $@ + command diff --color $@ } alias diff="color-diff" compdef _diff color-diff # compdef is already loaded by this point -- cgit v1.2.3-70-g09d2 From b54ef89fab89eaa62ece588f96d8cbd7c222d854 Mon Sep 17 00:00:00 2001 From: WaferJay <17383312+WaferJay@users.noreply.github.com> Date: Fri, 24 Feb 2023 05:32:40 +0800 Subject: fix(af-magic): fix logic for separator with virtualenv (#11518) --- themes/af-magic.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index 1b629e43a..70549d01f 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -6,7 +6,8 @@ # dashed separator size function afmagic_dashes { # check either virtualenv or condaenv variables - local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}" + local python_env_dir="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}" + local python_env="${python_env_dir##*/}" # if there is a python virtual environment and it is displayed in # the prompt, account for it when returning the number of dashes -- cgit v1.2.3-70-g09d2 From 8a008e1f51d451db21232edd6f1709e6c5ea334e Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 23 Feb 2023 23:00:31 +0100 Subject: fix(azure): load completion properly for brew (#11499) Closes #11497 --- plugins/azure/azure.plugin.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh index 7bb173a5c..51b54dbc1 100644 --- a/plugins/azure/azure.plugin.zsh +++ b/plugins/azure/azure.plugin.zsh @@ -32,12 +32,14 @@ function _az-homebrew-installed() { (( $+commands[brew] )) || return 1 # speculatively check default brew prefix - if [ -h /usr/local/opt/az ]; then - _brew_prefix=/usr/local/opt/az + if [[ -d /usr/local ]]; then + _brew_prefix=/usr/local + elif [[ -d /opt/homebrew ]]; then + _brew_prefix=/opt/homebrew else # ok, it is not in the default prefix # this call to brew is expensive (about 400 ms), so at least let's make it only once - _brew_prefix=$(brew --prefix azure-cli) + _brew_prefix=$(brew --prefix) fi } @@ -49,12 +51,12 @@ _az_zsh_completer_path="$commands[az_zsh_completer.sh]" if [[ -z $_az_zsh_completer_path ]]; then # Homebrew if _az-homebrew-installed; then - _az_zsh_completer_path=$_brew_prefix/libexec/bin/az.completion.sh + _az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az # Linux else _az_zsh_completer_path=/etc/bash_completion.d/azure-cli fi fi -[[ -r $_az_zsh_completer_path ]] && source $_az_zsh_completer_path +[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path unset _az_zsh_completer_path _brew_prefix -- cgit v1.2.3-70-g09d2 From bd9c216fe04a1542913f524cad1719797ce39ba2 Mon Sep 17 00:00:00 2001 From: Zoltán Reegn Date: Fri, 24 Feb 2023 17:27:15 +0100 Subject: feat(iterm2): add shell integration script (#11509) --- plugins/iterm2/README.md | 12 ++ plugins/iterm2/iterm2.plugin.zsh | 11 ++ plugins/iterm2/iterm2_shell_integration.zsh | 178 ++++++++++++++++++++++++++++ plugins/iterm2/update | 4 + 4 files changed, 205 insertions(+) create mode 100644 plugins/iterm2/iterm2_shell_integration.zsh create mode 100755 plugins/iterm2/update diff --git a/plugins/iterm2/README.md b/plugins/iterm2/README.md index 50cdebf5e..3d11622df 100644 --- a/plugins/iterm2/README.md +++ b/plugins/iterm2/README.md @@ -2,11 +2,20 @@ This plugin adds a few functions that are useful when using [iTerm2](https://www.iterm2.com/). + To use it, add _iterm2_ to the plugins array of your zshrc file: ``` plugins=(... iterm2) ``` +Optionally, the plugin also applies the [Shell Integration Script for iTerm2](https://iterm2.com/documentation-shell-integration.html). +You can enable the integration with zstyle. It's important to add this line +before the line sourcing oh-my-zsh: + +``` +zstyle :omz:plugins:iterm2 shell-integration yes +``` + ## Plugin commands * `_iterm2_command ` @@ -24,6 +33,9 @@ plugins=(... iterm2) * `iterm2_tab_color_reset` resets the color of iTerm2's current tab back to default. + +For shell integration features see the [official documentation](https://iterm2.com/documentation-shell-integration.html). + ## Contributors - [Aviv Rosenberg](https://github.com/avivrosenberg) diff --git a/plugins/iterm2/iterm2.plugin.zsh b/plugins/iterm2/iterm2.plugin.zsh index 9d8e40bf6..d00232a30 100644 --- a/plugins/iterm2/iterm2.plugin.zsh +++ b/plugins/iterm2/iterm2.plugin.zsh @@ -7,6 +7,17 @@ # This plugin is only relevant if the terminal is iTerm2 on OSX. if [[ "$OSTYPE" == darwin* ]] && [[ -n "$ITERM_SESSION_ID" ]] ; then + # maybe make it the default in the future and allow opting out? + if zstyle -t ':omz:plugins:iterm2' shell-integration; then + # 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}" + + # See official docs: https://iterm2.com/documentation-shell-integration.html + source "${0:A:h}/iterm2_shell_integration.zsh" + fi + ### # Executes an arbitrary iTerm2 command via an escape code sequence. # See https://iterm2.com/documentation-escape-codes.html for all supported commands. diff --git a/plugins/iterm2/iterm2_shell_integration.zsh b/plugins/iterm2/iterm2_shell_integration.zsh new file mode 100644 index 000000000..7871ddded --- /dev/null +++ b/plugins/iterm2/iterm2_shell_integration.zsh @@ -0,0 +1,178 @@ +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +if [[ -o interactive ]]; then + if [ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "tmux-256color" -a "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "screen" -a "${ITERM_SHELL_INTEGRATION_INSTALLED-}" = "" -a "$TERM" != linux -a "$TERM" != dumb ]; then + ITERM_SHELL_INTEGRATION_INSTALLED=Yes + ITERM2_SHOULD_DECORATE_PROMPT="1" + # Indicates start of command output. Runs just before command executes. + iterm2_before_cmd_executes() { + if [ "$TERM_PROGRAM" = "iTerm.app" ]; then + printf "\033]133;C;\r\007" + else + printf "\033]133;C;\007" + fi + } + + iterm2_set_user_var() { + printf "\033]1337;SetUserVar=%s=%s\007" "$1" $(printf "%s" "$2" | base64 | tr -d '\n') + } + + # Users can write their own version of this method. It should call + # iterm2_set_user_var but not produce any other output. + # e.g., iterm2_set_user_var currentDirectory $PWD + # Accessible in iTerm2 (in a badge now, elsewhere in the future) as + # \(user.currentDirectory). + whence -v iterm2_print_user_vars > /dev/null 2>&1 + if [ $? -ne 0 ]; then + iterm2_print_user_vars() { + true + } + fi + + iterm2_print_state_data() { + local _iterm2_hostname="${iterm2_hostname-}" + if [ -z "${iterm2_hostname:-}" ]; then + _iterm2_hostname=$(hostname -f 2>/dev/null) + fi + printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "${_iterm2_hostname-}" + printf "\033]1337;CurrentDir=%s\007" "$PWD" + iterm2_print_user_vars + } + + # Report return code of command; runs after command finishes but before prompt + iterm2_after_cmd_executes() { + printf "\033]133;D;%s\007" "$STATUS" + iterm2_print_state_data + } + + # Mark start of prompt + iterm2_prompt_mark() { + printf "\033]133;A\007" + } + + # Mark end of prompt + iterm2_prompt_end() { + printf "\033]133;B\007" + } + + # There are three possible paths in life. + # + # 1) A command is entered at the prompt and you press return. + # The following steps happen: + # * iterm2_preexec is invoked + # * PS1 is set to ITERM2_PRECMD_PS1 + # * ITERM2_SHOULD_DECORATE_PROMPT is set to 1 + # * The command executes (possibly reading or modifying PS1) + # * iterm2_precmd is invoked + # * ITERM2_PRECMD_PS1 is set to PS1 (as modified by command execution) + # * PS1 gets our escape sequences added to it + # * zsh displays your prompt + # * You start entering a command + # + # 2) You press ^C while entering a command at the prompt. + # The following steps happen: + # * (iterm2_preexec is NOT invoked) + # * iterm2_precmd is invoked + # * iterm2_before_cmd_executes is called since we detected that iterm2_preexec was not run + # * (ITERM2_PRECMD_PS1 and PS1 are not messed with, since PS1 already has our escape + # sequences and ITERM2_PRECMD_PS1 already has PS1's original value) + # * zsh displays your prompt + # * You start entering a command + # + # 3) A new shell is born. + # * PS1 has some initial value, either zsh's default or a value set before this script is sourced. + # * iterm2_precmd is invoked + # * ITERM2_SHOULD_DECORATE_PROMPT is initialized to 1 + # * ITERM2_PRECMD_PS1 is set to the initial value of PS1 + # * PS1 gets our escape sequences added to it + # * Your prompt is shown and you may begin entering a command. + # + # Invariants: + # * ITERM2_SHOULD_DECORATE_PROMPT is 1 during and just after command execution, and "" while the prompt is + # shown and until you enter a command and press return. + # * PS1 does not have our escape sequences during command execution + # * After the command executes but before a new one begins, PS1 has escape sequences and + # ITERM2_PRECMD_PS1 has PS1's original value. + iterm2_decorate_prompt() { + # This should be a raw PS1 without iTerm2's stuff. It could be changed during command + # execution. + ITERM2_PRECMD_PS1="$PS1" + ITERM2_SHOULD_DECORATE_PROMPT="" + + # Add our escape sequences just before the prompt is shown. + # Use ITERM2_SQUELCH_MARK for people who can't mdoify PS1 directly, like powerlevel9k users. + # This is gross but I had a heck of a time writing a correct if statetment for zsh 5.0.2. + local PREFIX="" + if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then + PREFIX="" + elif [[ "${ITERM2_SQUELCH_MARK-}" != "" ]]; then + PREFIX="" + else + PREFIX="%{$(iterm2_prompt_mark)%}" + fi + PS1="$PREFIX$PS1%{$(iterm2_prompt_end)%}" + ITERM2_DECORATED_PS1="$PS1" + } + + iterm2_precmd() { + local STATUS="$?" + if [ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]; then + # You pressed ^C while entering a command (iterm2_preexec did not run) + iterm2_before_cmd_executes + if [ "$PS1" != "${ITERM2_DECORATED_PS1-}" ]; then + # PS1 changed, perhaps in another precmd. See issue 9938. + ITERM2_SHOULD_DECORATE_PROMPT="1" + fi + fi + + iterm2_after_cmd_executes "$STATUS" + + if [ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]; then + iterm2_decorate_prompt + fi + } + + # This is not run if you press ^C while entering a command. + iterm2_preexec() { + # Set PS1 back to its raw value prior to executing the command. + PS1="$ITERM2_PRECMD_PS1" + ITERM2_SHOULD_DECORATE_PROMPT="1" + iterm2_before_cmd_executes + } + + # If hostname -f is slow on your system set iterm2_hostname prior to + # sourcing this script. We know it is fast on macOS so we don't cache + # it. That lets us handle the hostname changing like when you attach + # to a VPN. + if [ -z "${iterm2_hostname-}" ]; then + if [ "$(uname)" != "Darwin" ]; then + iterm2_hostname=`hostname -f 2>/dev/null` + # Some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option. + if [ $? -ne 0 ]; then + iterm2_hostname=`hostname` + fi + fi + fi + + [[ -z ${precmd_functions-} ]] && precmd_functions=() + precmd_functions=($precmd_functions iterm2_precmd) + + [[ -z ${preexec_functions-} ]] && preexec_functions=() + preexec_functions=($preexec_functions iterm2_preexec) + + iterm2_print_state_data + printf "\033]1337;ShellIntegrationVersion=14;shell=zsh\007" + fi +fi diff --git a/plugins/iterm2/update b/plugins/iterm2/update new file mode 100755 index 000000000..da8dae690 --- /dev/null +++ b/plugins/iterm2/update @@ -0,0 +1,4 @@ +#!/bin/sh + +curl -s -L https://iterm2.com/shell_integration/zsh \ + -o iterm2_shell_integration.zsh -- cgit v1.2.3-70-g09d2 From 5cb943eea46d322542c5c2a9f54b201eddc2aa67 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 24 Feb 2023 17:27:23 +0100 Subject: fix(lib): fix return code after expected non-zero exit code (#11524) Fixes #11524 --- lib/directories.zsh | 2 +- lib/vcs_info.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index 091140626..9274b5f5f 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -8,7 +8,7 @@ setopt pushdminus # to your `zshrc` before loading `oh-my-zsh.sh` # to disable the following aliases and functions -zstyle -T ':omz:directories' aliases || return +zstyle -T ':omz:directories' aliases || return 0 alias -g ...='../..' alias -g ....='../../..' diff --git a/lib/vcs_info.zsh b/lib/vcs_info.zsh index e60938c14..be6d32ee9 100644 --- a/lib/vcs_info.zsh +++ b/lib/vcs_info.zsh @@ -38,7 +38,7 @@ # due to malicious input as a consequence of CVE-2021-45444, which affects # zsh versions from 5.0.3 to 5.8. # -autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return +autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return 0 # We use $tmp here because it's already a local variable in VCS_INFO_formats typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"' -- cgit v1.2.3-70-g09d2 From 277f38212aef31a6baba2cf1a0a355af611be5e0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 24 Feb 2023 20:55:31 +0100 Subject: refactor: reorganize setopts in lib folder --- lib/directories.zsh | 1 + lib/misc.zsh | 8 +++----- lib/theme-and-appearance.zsh | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index 9274b5f5f..13b680c19 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -1,4 +1,5 @@ # Changing/making/removing directory +setopt auto_cd setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus diff --git a/lib/misc.zsh b/lib/misc.zsh index 1f637083a..132f33551 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -15,8 +15,9 @@ if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then done fi -## jobs -setopt long_list_jobs +setopt multios # enable redirect to multiple streams: echo >file1 >file2 +setopt long_list_jobs # show long list format job notifications +setopt interactivecomments # recognize comments env_default 'PAGER' 'less' env_default 'LESS' '-R' @@ -30,6 +31,3 @@ if (( $+commands[ack-grep] )); then elif (( $+commands[ack] )); then alias afind='ack -il' fi - -# recognize comments -setopt interactivecomments diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 1b64b51d4..208ab9ce5 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -53,8 +53,6 @@ if command diff --color /dev/null /dev/null &>/dev/null; then compdef _diff color-diff # compdef is already loaded by this point fi -setopt auto_cd -setopt multios setopt prompt_subst [[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" -- cgit v1.2.3-70-g09d2 From cd647b6dc6779a1aafa2bcc3a81ec10b65c783ac Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 26 Feb 2023 15:44:18 +0100 Subject: fix(gnu-utils): reset ls alias to use GNU-based --color argument (#11527) Fixes #11503 --- plugins/gnu-utils/gnu-utils.plugin.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index 9419127d8..6bd3e8463 100644 --- a/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -61,3 +61,14 @@ __gnu_utils_preexec() { autoload -Uz add-zsh-hook add-zsh-hook preexec __gnu_utils_preexec + +# lib/theme-and-appearance.zsh sets the alias for ls not knowing that +# we'll be using GNU ls. We'll reset this to use GNU ls --color. +# See https://github.com/ohmyzsh/ohmyzsh/issues/11503 +# +# The ls alias might look like: +# - ls='ls -G' +# - ls='gls --color=tty' +if [[ -x "${commands[gls]}" && "${aliases[ls]}" = (*-G*|gls*) ]]; then + alias ls='ls --color=tty' +fi -- cgit v1.2.3-70-g09d2 From 0ca8907f0e6185545c5e38f77ae2f09ca2a44e77 Mon Sep 17 00:00:00 2001 From: Jannik Date: Sun, 26 Feb 2023 20:37:03 +0100 Subject: fix(lib): fix case-insensitive completion for zsh 5.9 (#11526) --- lib/completion.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 2c5695487..63379b53f 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -18,9 +18,9 @@ if [[ "$CASE_SENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' else if [[ "$HYPHEN_INSENSITIVE" = true ]]; then - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*' else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*' fi fi unset CASE_SENSITIVE HYPHEN_INSENSITIVE -- cgit v1.2.3-70-g09d2 From 16050ab80e63f8e53c07777b4c2ae16ad085e5ad Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Sun, 26 Feb 2023 16:40:44 -0500 Subject: feat(macos): allow multiple man pages in `man-preview` (#11365) --- plugins/macos/README.md | 2 +- plugins/macos/macos.plugin.zsh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/macos/README.md b/plugins/macos/README.md index 1bc4244a4..1cb9b395d 100644 --- a/plugins/macos/README.md +++ b/plugins/macos/README.md @@ -25,7 +25,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) | `pxd` | Return the current Xcode project directory | | `cdx` | `cd` to the current Xcode project directory | | `quick-look` | Quick-Look a specified file | -| `man-preview` | Open a specified man page in Preview app | +| `man-preview` | Open man pages in Preview app | | `showfiles` | Show hidden files in Finder | | `hidefiles` | Hide the hidden files in Finder | | `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on | diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index e4d759dcf..e27d412c8 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -224,9 +224,10 @@ function quick-look() { } function man-preview() { - local location - # Don't let Preview.app steal focus if the man page doesn't exist - location=$(man -w "$@") && mandoc -Tpdf $location | open -f -a Preview + local page + for page in "${(@f)"$(man -w $@)"}"; do + command mandoc -Tpdf $page | open -f -a Preview + done } compdef _man man-preview -- cgit v1.2.3-70-g09d2 From 21bdb18b2d1fe8b547a42da7ac7b58fb28563a2c Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Monti Date: Mon, 27 Feb 2023 20:22:39 +0100 Subject: feat(nodenv): add plugin for `nodenv` (#9880) Co-authored-by: Matthew Boston --- plugins/nodenv/README.md | 20 +++++++++++++++++++ plugins/nodenv/nodenv.plugin.zsh | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 plugins/nodenv/README.md create mode 100644 plugins/nodenv/nodenv.plugin.zsh diff --git a/plugins/nodenv/README.md b/plugins/nodenv/README.md new file mode 100644 index 000000000..550597025 --- /dev/null +++ b/plugins/nodenv/README.md @@ -0,0 +1,20 @@ +# nodenv plugin + +The primary job of this plugin is to provide `nodenv_prompt_info` which can be added to your theme to include Node +version information into your prompt. + +To use it, add `nodenv` to the plugins array in your zshrc file: + +```zsh +plugins=(... nodenv) +``` + +## Functions + +* `nodenv_prompt_info`: displays the Node version in use by nodenv; or the global Node + version, if nodenv wasn't found. You can use this function in your prompt by adding + `$(nodenv_prompt_info)` to PROMPT or RPROMPT: + + ```zsh + RPROMPT='$(nodenv_prompt_info)' + ``` diff --git a/plugins/nodenv/nodenv.plugin.zsh b/plugins/nodenv/nodenv.plugin.zsh new file mode 100644 index 000000000..79a4ffbb5 --- /dev/null +++ b/plugins/nodenv/nodenv.plugin.zsh @@ -0,0 +1,43 @@ +# This plugin loads nodenv into the current shell and provides prompt info via +# the 'nodenv_prompt_info' function. + +FOUND_NODENV=${+commands[nodenv]} + +if [[ $FOUND_NODENV -ne 1 ]]; then + nodenvdirs=( + "$HOME/.nodenv" + "/usr/local/nodenv" + "/opt/nodenv" + "/usr/local/opt/nodenv" + ) + for dir in $nodenvdirs; do + if [[ -d "${dir}/bin" ]]; then + export PATH="$PATH:${dir}/bin" + FOUND_NODENV=1 + break + fi + done + + if [[ $FOUND_NODENV -ne 1 ]]; then + if (( $+commands[brew] )) && dir=$(brew --prefix nodenv 2>/dev/null); then + if [[ -d "${dir}/bin" ]]; then + export PATH="$PATH:${dir}/bin" + FOUND_NODENV=1 + fi + fi + fi +fi + +if [[ $FOUND_NODENV -eq 1 ]]; then + eval "$(nodenv init --no-rehash - zsh)" + function nodenv_prompt_info() { + nodenv version-name 2>/dev/null + } +else + # fallback to system node + function nodenv_prompt_info() { + echo "system: $(node -v 2>&1 | cut -c 2-)" + } +fi + +unset FOUND_NODENV nodenvdirs dir -- cgit v1.2.3-70-g09d2 From f42c965da44be6940134b805edb54c5eca37d9ae Mon Sep 17 00:00:00 2001 From: ZYX Date: Mon, 27 Feb 2023 14:39:38 -0500 Subject: fix(aliases): clarify how to pass in keywords to `acs` (#11521) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/aliases/README.md | 2 +- plugins/aliases/cheatsheet.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index 4e77f67b3..6a2da3d74 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -19,7 +19,7 @@ Requirements: Python needs to be installed. - `acs -h/--help`: print help mesage -- `acs `: filter aliases by `` and highlight +- `acs `: filter and highlight aliases by `` - `acs -g /--group `: show only aliases for group ``. Multiple uses of the flag show all groups diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index 3362a6ab6..fb8c74aa4 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -51,18 +51,18 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False): continue aliases = cheatsheet.get(key) if not wfilter: - pretty_print_group(key, aliases, wfilter, groups_only) + pretty_print_group(key, aliases, only_groupname=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) + pretty_print_group(key, [ alias for alias in aliases if wfilter in alias[0] or wfilter in alias[1] ], wfilter) if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Pretty print aliases.") - parser.add_argument('filter', nargs="*", help="search aliases matching string") + parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs") + parser.add_argument('filter', nargs="*", metavar="", help="search aliases matching keywords") 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() group_list = args.group_list or None - wfilter = " ".join(args.filter) or None + wfilter = " ".join(args.filter[1:]) if args.filter else None pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only) -- cgit v1.2.3-70-g09d2 From b602e0a066d8c98e8c02201ad16c764447fd8531 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Feb 2023 20:46:42 +0100 Subject: fix(aliases): fix regression in filter argument --- plugins/aliases/cheatsheet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index fb8c74aa4..7505d304b 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -51,9 +51,9 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False): continue aliases = cheatsheet.get(key) if not wfilter: - pretty_print_group(key, aliases, only_groupname=groups_only) + pretty_print_group(key, aliases, wfilter, groups_only) else: - pretty_print_group(key, [ alias for alias in aliases if wfilter in alias[0] or wfilter in alias[1] ], wfilter) + 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.", prog="acs") @@ -64,5 +64,5 @@ if __name__ == '__main__': lines = sys.stdin.readlines() group_list = args.group_list or None - wfilter = " ".join(args.filter[1:]) if args.filter else None + wfilter = " ".join(args.filter) or None pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only) -- cgit v1.2.3-70-g09d2 From a4a9a8cd8ccb4240a7c5df5f6766bd5340646e63 Mon Sep 17 00:00:00 2001 From: Julian Suarez <49501306+jsred@users.noreply.github.com> Date: Wed, 1 Mar 2023 07:23:32 -0300 Subject: feat(rvm): add `rb32` alias (#11533) --- plugins/rvm/README.md | 1 + plugins/rvm/rvm.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/rvm/README.md b/plugins/rvm/README.md index 576b037b0..410bd60c0 100644 --- a/plugins/rvm/README.md +++ b/plugins/rvm/README.md @@ -24,6 +24,7 @@ plugins=(... rvm) | `rb27` | `rvm use ruby-2.7` | | `rb30` | `rvm use ruby-3.0` | | `rb31` | `rvm use ruby-3.1` | +| `rb32` | `rvm use ruby-3.2` | | `rvm-update` | `rvm get head` | | `gems` | `gem list` | | `rvms` | `rvm gemset` | diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 2a091d019..3ddf04176 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -27,6 +27,7 @@ rubies=( 27 'ruby-2.7' 30 'ruby-3.0' 31 'ruby-3.1' + 32 'ruby-3.2' ) for v in ${(k)rubies}; do -- cgit v1.2.3-70-g09d2 From 14978859c5b8d9385c9b836cd09c97cc08b6035b Mon Sep 17 00:00:00 2001 From: Batuhan Şanlı <32306925+batuhan0sanli@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:03:50 +0300 Subject: docs(brew): remove duplication (#11535) --- plugins/brew/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index d0c150237..412daae63 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -21,7 +21,6 @@ defined for convenience. | -------- | --------------------------------------- | ------------------------------------------------------------------- | | `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | | `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | -| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | | `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | | `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | | `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | -- cgit v1.2.3-70-g09d2 From 5bf7f9c83325a6cb2752e14ca01a574dbeef206e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 3 Mar 2023 12:34:31 +0100 Subject: fix(lib): use `$BROWSER` in `open_command` if set (#11532) Fixes #11098 --- lib/functions.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/functions.zsh b/lib/functions.zsh index 6e1faa6aa..1d85ea38a 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -30,6 +30,13 @@ function open_command() { ;; esac + # If a URL is passed, $BROWSER might be set to a local browser within SSH. + # See https://github.com/ohmyzsh/ohmyzsh/issues/11098 + if [[ -n "$BROWSER" && "$1" = (http|https)://* ]]; then + "$BROWSER" "$@" + return + fi + ${=open_cmd} "$@" &>/dev/null } -- cgit v1.2.3-70-g09d2 From 95d0c4b603e0c880bcf20bc9211b2162e94ed925 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 3 Mar 2023 14:38:50 +0100 Subject: refactor(theme-and-appearance): reorganize and clean up logic (#11529) Co-authored-by: Andrew Janke Co-authored-by: Marcelo Parada Co-authored-by: Uy Ha Co-authored-by: Valentin Uveges --- lib/theme-and-appearance.zsh | 135 ++++++++++++++++++++++++++----------------- 1 file changed, 81 insertions(+), 54 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 208ab9ce5..985d3bc11 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,66 +1,93 @@ -# ls colors +# Sets color variable such as $fg, $bg, $color and $reset_color autoload -U colors && colors -# Enable ls colors -export LSCOLORS="Gxfxcxdxbxegedabagacad" +# Expand variables and commands in PROMPT variables +setopt prompt_subst -# TODO organise this chaotic logic +# Prompt function theming defaults +ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Beginning of the git prompt, before the branch name +ZSH_THEME_GIT_PROMPT_SUFFIX=")" # End of the git prompt +ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty +ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean +ZSH_THEME_RUBY_PROMPT_PREFIX="(" +ZSH_THEME_RUBY_PROMPT_SUFFIX=")" -if [[ "$DISABLE_LS_COLORS" != "true" ]]; then - if [[ -d "$ZSH" ]]; then - _test_dir="$ZSH" - else - _test_dir="." - fi - # Find the option for using colors in ls, depending on the version - if [[ "$OSTYPE" == netbsd* ]]; then - # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); - # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' - elif [[ "$OSTYPE" == openbsd* ]]; then - # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, - # with color and multibyte support) are available from ports. "colorls" - # will be installed on purpose and can't be pulled in by installing - # coreutils, so prefer it to "gls". - gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' - colorls -G -d "$_test_dir" &>/dev/null && alias ls='colorls -G' - elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then - # this is a good alias, it works by default just using $LSCOLORS - ls -G "$_test_dir" &>/dev/null && alias ls='ls -G' - # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) - # otherwise, gls will use the default color scheme which is ugly af - [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d "$_test_dir" &>/dev/null && alias ls='gls --color=tty' - else - # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - if [[ -z "$LS_COLORS" ]]; then - (( $+commands[dircolors] )) && eval "$(dircolors -b)" +# Use diff --color if available +if command diff --color /dev/null{,} &>/dev/null; then + function diff { + command diff --color "$@" + } +fi + + +# Don't set ls coloring if disabled +[[ "$DISABLE_LS_COLORS" != true ]] || return 0 + +function test-ls-args { + local cmd="$1" # ls, gls, colorls, ... + local args="${@[2,-1]}" # arguments except the first one + command "$cmd" "$args" /dev/null &>/dev/null +} + +# Find the option for using colors in ls, depending on the version +case "$OSTYPE" in + netbsd*) + # On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors); + # otherwise, leave ls as is, because NetBSD's ls doesn't support -G + test-ls-args gls --color && alias ls='gls --color=tty' + ;; + openbsd*) + # On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base, + # with color and multibyte support) are available from ports. + # `colorls` will be installed on purpose and can't be pulled in by installing + # coreutils (which might be installed for ), so prefer it to `gls`. + test-ls-args gls --color && alias ls='gls --color=tty' + test-ls-args colorls -G && alias ls='colorls -G' + ;; + (darwin|freebsd)*) + # This alias works by default just using $LSCOLORS + test-ls-args ls -G && alias ls='ls -G' + # Only use GNU ls if installed and there are user defaults for $LS_COLORS, + # as the default coloring scheme is not very pretty + [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \ + && test-ls-args gls --color \ + && alias ls='gls --color=tty' + ;; + *) + if test-ls-args ls --color; then + alias ls='ls --color=tty' + elif test-ls-args ls -G; then + alias ls='ls -G' fi + ;; +esac - ls --color -d "$_test_dir" &>/dev/null && alias ls='ls --color=tty' || { ls -G "$_test_dir" &>/dev/null && alias ls='ls -G' } +unfunction test-ls-args - # Take advantage of $LS_COLORS for completion as well. - zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" - fi -fi -# enable diff color if possible. -if command diff --color /dev/null /dev/null &>/dev/null; then - function color-diff { - command diff --color $@ - } - alias diff="color-diff" - compdef _diff color-diff # compdef is already loaded by this point -fi +# Default coloring for BSD-based ls +export LSCOLORS="Gxfxcxdxbxegedabagacad" -setopt prompt_subst +# Default coloring for GNU-based ls +if [[ -z "$LS_COLORS" ]]; then + # Define LS_COLORS via dircolors if available. Otherwise, set a default + # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors) + if (( $+commands[dircolors] )); then + [[ -f "$HOME/.dircolors" ]] \ + && source <(dircolors -b "$HOME/.dircolors") \ + || source <(dircolors -b) + else + export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=37;41:sg=30;43:tw=30;42:ow=34;42:" + fi +fi -[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" +# Take advantage of $LS_COLORS for completion as well. +function omz_set_completion_colors { + zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" + add-zsh-hook -d precmd omz_set_completion_colors + unfunction omz_set_completion_colors +} -# git theming default: Variables for theming the git info prompt -ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name -ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt -ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty -ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean -ZSH_THEME_RUBY_PROMPT_PREFIX="(" -ZSH_THEME_RUBY_PROMPT_SUFFIX=")" +autoload -Uz add-zsh-hook +add-zsh-hook precmd omz_set_completion_colors -- cgit v1.2.3-70-g09d2 From 6f3304f442afde6e1cf3e7e8641a405d29d2e73d Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 4 Mar 2023 09:25:01 +0100 Subject: feat(argocd): add completion plugin Co-authored-by: Sumudu Lansakara Closes #9900 --- plugins/argocd/README.md | 20 ++++++++++++++++++++ plugins/argocd/gh.plugin.zsh | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/argocd/README.md create mode 100644 plugins/argocd/gh.plugin.zsh diff --git a/plugins/argocd/README.md b/plugins/argocd/README.md new file mode 100644 index 000000000..0f900ff22 --- /dev/null +++ b/plugins/argocd/README.md @@ -0,0 +1,20 @@ +# Argo CD plugin + +This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI. + +To use it, add `argocd` to the plugins array in your zshrc file: + +```zsh +plugins=(... argocd) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and is automatically updated asynchronously when the plugin is +loaded, which is usually when you start up a new terminal emulator. + +The cache is stored at: + +- `$ZSH_CACHE/completions/_argocd` completions script diff --git a/plugins/argocd/gh.plugin.zsh b/plugins/argocd/gh.plugin.zsh new file mode 100644 index 000000000..8de7b0238 --- /dev/null +++ b/plugins/argocd/gh.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for argocd. +if (( ! $+commands[argocd] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `argocd`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then + typeset -g -A _comps + autoload -Uz _argocd + _comps[argocd]=_argocd +fi + +argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &| -- cgit v1.2.3-70-g09d2 From 3b759c5dc926d0973d82fa1b8ffed45d770d20e8 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 6 Mar 2023 11:25:47 +0100 Subject: fix(argocd): typo in filename --- plugins/argocd/argocd.plugin.zsh | 14 ++++++++++++++ plugins/argocd/gh.plugin.zsh | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 plugins/argocd/argocd.plugin.zsh delete mode 100644 plugins/argocd/gh.plugin.zsh diff --git a/plugins/argocd/argocd.plugin.zsh b/plugins/argocd/argocd.plugin.zsh new file mode 100644 index 000000000..8de7b0238 --- /dev/null +++ b/plugins/argocd/argocd.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for argocd. +if (( ! $+commands[argocd] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `argocd`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then + typeset -g -A _comps + autoload -Uz _argocd + _comps[argocd]=_argocd +fi + +argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &| diff --git a/plugins/argocd/gh.plugin.zsh b/plugins/argocd/gh.plugin.zsh deleted file mode 100644 index 8de7b0238..000000000 --- a/plugins/argocd/gh.plugin.zsh +++ /dev/null @@ -1,14 +0,0 @@ -# Autocompletion for argocd. -if (( ! $+commands[argocd] )); then - return -fi - -# If the completion file doesn't exist yet, we need to autoload it and -# bind it to `argocd`. Otherwise, compinit will have already done that. -if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then - typeset -g -A _comps - autoload -Uz _argocd - _comps[argocd]=_argocd -fi - -argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &| -- cgit v1.2.3-70-g09d2 From 06c16175ea4aa81d4b64c0772f44c11e505a0eb7 Mon Sep 17 00:00:00 2001 From: Karim Benbourenane Date: Tue, 7 Mar 2023 03:25:34 -0500 Subject: fix(aliases): group properly aliases (#11546) --- plugins/aliases/cheatsheet.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index 7505d304b..f742fba9e 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -15,6 +15,7 @@ def parse(line): def cheatsheet(lines): exps = [ parse(line) for line in lines ] + exps.sort(key=lambda exp:exp[2]) cheatsheet = {'_default': []} for key, group in itertools.groupby(exps, lambda exp:exp[2]): group_list = [ item for item in group ] -- cgit v1.2.3-70-g09d2 From 46fd7972a2170388c9b8e9f6e58d6c8408ad4904 Mon Sep 17 00:00:00 2001 From: potato <851951875@qq.com> Date: Tue, 7 Mar 2023 20:33:16 +0800 Subject: feat(aws): add AWS_REGION to aws_prompt_info (#10062) --- plugins/aws/README.md | 22 +++++++++++++++++----- plugins/aws/aws.plugin.zsh | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/plugins/aws/README.md b/plugins/aws/README.md index d6f4f4600..e1e355741 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -1,7 +1,7 @@ # aws This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html) -and a few utilities to manage AWS profiles and display them in the prompt. +and a few utilities to manage AWS profiles/regions and display them in the prompt. To use it, add `aws` to the plugins array in your zshrc file. @@ -16,6 +16,9 @@ plugins=(... aws) Run `asp` without arguments to clear the profile. * `asp [] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection. +* `asr []`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to ``. + Run `asr` without arguments to clear the profile. + * `acp [] []`: in addition to `asp` functionality, it actually changes the profile by assuming the role specified in the `` configuration. It supports MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if @@ -25,25 +28,34 @@ plugins=(... aws) * `agp`: gets the current value of `$AWS_PROFILE`. +* `agr`: gets the current value of `$AWS_REGION`. + * `aws_change_access_key`: changes the AWS access key of a profile. * `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`). Used to provide completion for the `asp` function. +* `aws_regions`: lists the available regions. + Used to provide completion for the `asr` function. + ## Plugin options * Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to - see the AWS profile prompt. + see the AWS profile/region prompt. ## Theme The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays -the current `$AWS_PROFILE`. It uses two variables to control how that is shown: +the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown: + +* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to ``. -* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to ``. +* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`. ## Configuration diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 865e82f19..1c386a3e1 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -2,6 +2,10 @@ function agp() { echo $AWS_PROFILE } +function agr() { + echo $AWS_REGION +} + # AWS profile selection function asp() { if [[ -z "$1" ]]; then @@ -27,6 +31,25 @@ function asp() { fi } +# AWS region selection +function asr() { + if [[ -z "$1" ]]; then + unset AWS_DEFAULT_REGION AWS_REGION + echo AWS region cleared. + return + fi + + local -a available_regions + available_regions=($(aws_regions)) + if [[ -z "${available_regions[(r)$1]}" ]]; then + echo "${fg[red]}Available regions: \n$(aws_regions)" + return 1 + fi + + export AWS_REGION=$1 + export AWS_DEFAULT_REGION=$1 +} + # AWS profile switch function acp() { if [[ -z "$1" ]]; then @@ -145,12 +168,25 @@ function aws_change_access_key() { AWS_PAGER="" aws iam list-access-keys } +function aws_regions() { + if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then + aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}' + else + echo "You must specify a AWS profile." + fi +} + function aws_profiles() { aws --no-cli-pager configure list-profiles 2> /dev/null && return [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g' } +function _aws_regions() { + reply=($(aws_regions)) +} +compctl -K _aws_regions asr + function _aws_profiles() { reply=($(aws_profiles)) } @@ -158,8 +194,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key # AWS prompt function aws_prompt_info() { - [[ -n "$AWS_PROFILE" ]] || return - echo "${ZSH_THEME_AWS_PREFIX=}" + if [[ -z $AWS_REGION && -z $AWS_PROFILE ]];then return; fi + echo "${ZSH_THEME_AWS_PROFILE_PREFIX:=} ${ZSH_THEME_AWS_REGION_PREFIX:=}" } if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then @@ -211,3 +247,4 @@ else [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path unset _aws_zsh_completer_path _brew_prefix fi + -- cgit v1.2.3-70-g09d2 From d342b353e32091ef7384b86fd86b1a88dbd44609 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 7 Mar 2023 18:49:17 +0100 Subject: fix(init): set completion colors on theme load, not with `precmd` This fixes an edge case where the user actually sets zstyle ':completion:*' list-colors in their zshrc, but the previous code used a precmd hook, which would override the user changes. With this change our modifications will be set in the init script, after the theme loads, so that later changes can affect our defaults. Note that this will not be run for users on plugin managers, as these don't generally run our init script. --- lib/theme-and-appearance.zsh | 10 ---------- oh-my-zsh.sh | 3 +++ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 985d3bc11..e245570e3 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -81,13 +81,3 @@ if [[ -z "$LS_COLORS" ]]; then export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=37;41:sg=30;43:tw=30;42:ow=34;42:" fi fi - -# Take advantage of $LS_COLORS for completion as well. -function omz_set_completion_colors { - zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" - add-zsh-hook -d precmd omz_set_completion_colors - unfunction omz_set_completion_colors -} - -autoload -Uz add-zsh-hook -add-zsh-hook precmd omz_set_completion_colors diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 98bda8c8b..363cfca8b 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -189,3 +189,6 @@ if [[ -n "$ZSH_THEME" ]]; then echo "[oh-my-zsh] theme '$ZSH_THEME' not found" fi fi + +# set completion colors to be the same as `ls`, after theme has been loaded +[[ -z "$LS_COLORS" ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -- cgit v1.2.3-70-g09d2 From e0f92c8df52335c266f73e3cc3384b277f3e9a34 Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Tue, 7 Mar 2023 21:46:21 +0200 Subject: feat(vi-mode): add settings for vi-mode cursor styles (#10860) --- plugins/vi-mode/README.md | 21 +++++++++++++++++++++ plugins/vi-mode/vi-mode.plugin.zsh | 23 ++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 476666bf6..3b819c7cb 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -29,6 +29,8 @@ plugins=(... vi-mode) VI_MODE_SET_CURSOR=true ``` + See [Cursor Styles](#cursor-styles) for controlling how the cursor looks in different modes + - `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode. See [Mode indicators](#mode-indicators) for details. @@ -52,6 +54,25 @@ INSERT_MODE_INDICATOR="%F{yellow}+%f" You can also use the `vi_mode_prompt_info` function in your prompt, which will display this mode indicator. +## Cursor Styles + +You can control the cursor style used in each active vim mode by changing the values of the following variables. + +```zsh +# defaults +VI_MODE_CURSOR_NORMAL=2 +VI_MODE_CURSOR_VISUAL=6 +VI_MODE_CURSOR_INSERT=6 +VI_MODE_CURSOR_OPPEND=0 +``` + +- 0, 1 - Blinking block +- 2 - Solid block +- 3 - Blinking underline +- 4 - Solid underline +- 5 - Blinking line +- 6 - Solid line + ## Key bindings Use `ESC` or `CTRL-[` to enter `Normal mode`. diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 149d6bbd5..9a410c1fb 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -14,6 +14,15 @@ typeset -g VI_MODE_RESET_PROMPT_ON_MODE_CHANGE # Unset or set to any other value to do the opposite. typeset -g VI_MODE_SET_CURSOR +# Control how the cursor appears in the various vim modes. This only applies +# if $VI_MODE_SET_CURSOR=true. +# +# See https://vt100.net/docs/vt510-rm/DECSCUSR for cursor styles +typeset -g VI_MODE_CURSOR_NORMAL=2 +typeset -g VI_MODE_CURSOR_VISUAL=6 +typeset -g VI_MODE_CURSOR_INSERT=6 +typeset -g VI_MODE_CURSOR_OPPEND=0 + typeset -g VI_KEYMAP=main function _vi-mode-set-cursor-shape-for-keymap() { @@ -22,13 +31,13 @@ function _vi-mode-set-cursor-shape-for-keymap() { # https://vt100.net/docs/vt510-rm/DECSCUSR local _shape=0 case "${1:-${VI_KEYMAP:-main}}" in - main) _shape=6 ;; # vi insert: line - viins) _shape=6 ;; # vi insert: line - isearch) _shape=6 ;; # inc search: line - command) _shape=6 ;; # read a command name - vicmd) _shape=2 ;; # vi cmd: block - visual) _shape=2 ;; # vi visual mode: block - viopp) _shape=0 ;; # vi operation pending: blinking block + main) _shape=$VI_MODE_CURSOR_INSERT ;; # vi insert: line + viins) _shape=$VI_MODE_CURSOR_INSERT ;; # vi insert: line + isearch) _shape=$VI_MODE_CURSOR_INSERT ;; # inc search: line + command) _shape=$VI_MODE_CURSOR_INSERT ;; # read a command name + vicmd) _shape=$VI_MODE_CURSOR_NORMAL ;; # vi cmd: block + visual) _shape=$VI_MODE_CURSOR_VISUAL ;; # vi visual mode: block + viopp) _shape=$VI_MODE_CURSOR_OPPEND ;; # vi operation pending: blinking block *) _shape=0 ;; esac printf $'\e[%d q' "${_shape}" -- cgit v1.2.3-70-g09d2 From 1c325de464117aa058d5f810b96ed54d65e5d0d5 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Tue, 7 Mar 2023 11:52:38 -0800 Subject: Fixing link to PA website in README Was linking to an old URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f4a26cab..4042c8c26 100644 --- a/README.md +++ b/README.md @@ -374,4 +374,4 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt). ![Planet Argon](https://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg) -Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github). +Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](http://www.planetargon.com/services/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github). -- cgit v1.2.3-70-g09d2 From 3ea0e0d2343a2e79be0c2c6ace030a595d5cec2f Mon Sep 17 00:00:00 2001 From: Benjamin Lieb Date: Wed, 8 Mar 2023 03:29:21 -0500 Subject: docs(vi-mode): document how to add vi-mode info on the prompt (#11548) --- plugins/vi-mode/README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 3b819c7cb..0cb516751 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -51,8 +51,23 @@ MODE_INDICATOR="%F{white}+%f" INSERT_MODE_INDICATOR="%F{yellow}+%f" ``` -You can also use the `vi_mode_prompt_info` function in your prompt, which will display -this mode indicator. +### Adding mode indicators to your prompt + +`Vi-mode` by default will add mode indicators to `RPROMPT` **unless** that is defined by +a preceding plugin. + +If `PROMPT` or `RPROMPT` is not defined to your liking, you can add mode info manually. The `vi_mode_prompt_info` function is available to insert mode indicator information. + +Here are some examples: + +```bash +source $ZSH/oh-my-zsh.sh + +PROMPT="$PROMPT\$(vi_mode_prompt_info)" +RPROMPT="\$(vi_mode_prompt_info)$RPROMPT" +``` + +Note the `\$` here, which importantly prevents interpolation at the time of defining, but allows it to be executed for each prompt update event. ## Cursor Styles -- cgit v1.2.3-70-g09d2 From 92387d9fff83934a8628697a4397a65030f0301e Mon Sep 17 00:00:00 2001 From: Zhong Zheng Date: Sat, 11 Mar 2023 01:52:44 +1100 Subject: feat(rails): add `rta` alias (#11553) --- plugins/rails/README.md | 1 + plugins/rails/rails.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/rails/README.md b/plugins/rails/README.md index fa66750f0..b2425aabc 100644 --- a/plugins/rails/README.md +++ b/plugins/rails/README.md @@ -47,6 +47,7 @@ plugins=(... rails) | `rsp` | `rails server --port` | Launch a web server and specify the listening port | | `rsts` | `rails stats` | Print code statistics | | `rt` | `rails test` | Run Rails tests | +| `rta` | `rails test:all` | Runs all Rails tests, including system tests | | `ru` | `rails runner` | Run Ruby code in the context of Rails | ### Foreman diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index b11cbb5c7..015dc9ecb 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -75,6 +75,7 @@ alias rsd='rails server --debugger' alias rsp='rails server --port' alias rsts='rails stats' alias rt='rails test' +alias rta='rails test:all' alias ru='rails runner' # Foreman aliases -- cgit v1.2.3-70-g09d2 From 72732a224e886933df6b64a49ec6f5e94c884612 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 12 Mar 2023 15:47:58 +0100 Subject: fix(lib): set equivalent LS_COLORS and LSCOLORS variables As reported by https://geoff.greer.fm/lscolors Fixes #11554 --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index e245570e3..d8859b04c 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -78,6 +78,6 @@ if [[ -z "$LS_COLORS" ]]; then && source <(dircolors -b "$HOME/.dircolors") \ || source <(dircolors -b) else - export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=37;41:sg=30;43:tw=30;42:ow=34;42:" + export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43" fi fi -- cgit v1.2.3-70-g09d2