From 01c82c381d90f10239908ace41df9532c8c45495 Mon Sep 17 00:00:00 2001 From: Alexander Huynh Date: Fri, 7 Apr 2023 07:35:12 -0400 Subject: [PATCH 01/47] fix(jump): even spacing between marks (#11601) --- plugins/jump/jump.plugin.zsh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index c2da1144e..829c9d9cb 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -35,12 +35,11 @@ marks() { max=${#link:t} fi done - local printf_markname_template="$(printf -- "%%%us " "$max")" + local printf_markname_template="$(printf -- "%%%us" "$max")" for link in $MARKPATH/{,.}*(@N); do - local markname="$fg[cyan]${link:t}$reset_color" + local markname="$fg[cyan]$(printf -- "$printf_markname_template" "${link:t}")$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" - printf -- "$printf_markname_template" "$markname" - printf -- "-> %s\n" "$markpath" + printf -- "%s -> %s\n" "$markname" "$markpath" done } From 9b1ef262bcc8d47a6d20b4efc673557560df6647 Mon Sep 17 00:00:00 2001 From: deimosian Date: Fri, 7 Apr 2023 11:43:45 +0000 Subject: [PATCH 02/47] feat(archlinux): unify `upgrade` function (#11597) Co-authored-by: Carlo Sala --- plugins/archlinux/archlinux.plugin.zsh | 31 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 4f1364779..e3b1b1261 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -23,7 +23,6 @@ alias pacfiles='pacman -F' alias pacls='pacman -Ql' alias pacown='pacman -Qo' alias pacupd="sudo pacman -Sy" -alias upgrade='sudo pacman -Syu' function paclist() { # Based on https://bbs.archlinux.org/viewtopic.php?id=93683 @@ -109,7 +108,6 @@ if (( $+commands[aura] )); then alias auupd="sudo aura -Sy" alias auupg='sudo sh -c "aura -Syu && aura -Au"' alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"' - alias upgrade='sudo aura -Syu' # extra bonus specially for aura alias auown="aura -Qqo" @@ -136,7 +134,6 @@ if (( $+commands[pacaur] )); then alias painsd='pacaur -S --asdeps' alias pamir='pacaur -Syy' alias paupd="pacaur -Sy" - alias upgrade='pacaur -Syu' fi if (( $+commands[trizen] )); then @@ -158,7 +155,6 @@ if (( $+commands[trizen] )); then alias trinsd='trizen -S --asdeps' alias trmir='trizen -Syy' alias trupd="trizen -Sy" - alias upgrade='trizen -Syu' fi if (( $+commands[yay] )); then @@ -180,5 +176,30 @@ if (( $+commands[yay] )); then alias yainsd='yay -S --asdeps' alias yamir='yay -Syy' alias yaupd="yay -Sy" - alias upgrade='yay -Syu' fi + +# Check Arch Linux PGP Keyring before System Upgrade to prevent failure. +function upgrade() { + echo "[oh-my-zsh] Checking Arch Linux PGP Keyring" + local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" + local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" + if [ $installedver != $currentver ]; then + echo "[oh-my-zsh] Arch Linux PGP Keyring is out of date." + echo "[oh-my-zsh] Updating before full system upgrade." + sudo pacman -Syu --needed --noconfirm archlinux-keyring + else + echo "[oh-my-zsh] Arch Linux PGP Keyring is up to date." + fi + echo "[oh-mh-zsh] Proceeding with full system upgrade." + if (( $+commands[yay] )); then + yay -Syu + elif (( $+commands[trizen] )); then + trizen -Syu + elif (( $+commands[pacaur] )); then + pacaur -Syu + elif (( $+commands[aura] )); then + sudo aura -Syu + else + sudo pacman -Syu + fi +} From e906a3130eb5031a2c82d9187ea17387881631db Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 8 Apr 2023 11:13:30 +0200 Subject: [PATCH 03/47] fix(azure): look properly for azure config file Closes #11606 --- plugins/azure/azure.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh index 51b54dbc1..8fec3c1f7 100644 --- a/plugins/azure/azure.plugin.zsh +++ b/plugins/azure/azure.plugin.zsh @@ -18,10 +18,10 @@ compctl -K _az_subscriptions azss # Azure prompt function azure_prompt_info() { - [[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}" ]] && return + [[ ! -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}) + azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json") echo "${ZSH_THEME_AZURE_PREFIX:=}" } From ad99f0c164111fa3cfcbfc5b9cda321800541936 Mon Sep 17 00:00:00 2001 From: Aleks Date: Sat, 8 Apr 2023 13:36:54 +0200 Subject: [PATCH 04/47] feat(git): add merge squash alias (`gms`) (#10937) --- 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 0895ce39c..f87d3fbca 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -116,6 +116,7 @@ plugins=(... git) | gloga | git log --oneline --decorate --graph --all | | glp | git log --pretty=\ | | gm | git merge | +| gms | git merge --squash | | gmom | git merge origin/$(git_main_branch) | | gmtl | git mergetool --no-prompt | | gmtlvim | git mergetool --no-prompt --tool=vimdiff | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index ed17436e8..3c8d53c8c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -237,6 +237,7 @@ alias gmtl='git mergetool --no-prompt' alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' alias gmum='git merge upstream/$(git_main_branch)' alias gma='git merge --abort' +alias gms="git merge --squash" alias gp='git push' alias gpd='git push --dry-run' From 90ec2d1a68049d8b7e57b87c3661d8cacf54655c Mon Sep 17 00:00:00 2001 From: deimosian Date: Sun, 9 Apr 2023 04:24:55 -0400 Subject: [PATCH 05/47] fix(archlinux): keyring update function (#11607) --- plugins/archlinux/archlinux.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index e3b1b1261..ce7bfdf23 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -186,7 +186,7 @@ function upgrade() { if [ $installedver != $currentver ]; then echo "[oh-my-zsh] Arch Linux PGP Keyring is out of date." echo "[oh-my-zsh] Updating before full system upgrade." - sudo pacman -Syu --needed --noconfirm archlinux-keyring + sudo pacman -Sy --needed --noconfirm archlinux-keyring else echo "[oh-my-zsh] Arch Linux PGP Keyring is up to date." fi From 4586808f86bf3bfdf97685380472b63597ce43c0 Mon Sep 17 00:00:00 2001 From: deimosian Date: Sun, 9 Apr 2023 06:58:38 -0400 Subject: [PATCH 06/47] feat(archlinux): improve update function messages (#11608) --- plugins/archlinux/archlinux.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index ce7bfdf23..da170f488 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -180,17 +180,17 @@ fi # Check Arch Linux PGP Keyring before System Upgrade to prevent failure. function upgrade() { - echo "[oh-my-zsh] Checking Arch Linux PGP Keyring" + echo ":: Checking Arch Linux PGP Keyring..." local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" if [ $installedver != $currentver ]; then - echo "[oh-my-zsh] Arch Linux PGP Keyring is out of date." - echo "[oh-my-zsh] Updating before full system upgrade." + echo " Arch Linux PGP Keyring is out of date." + echo " Updating before full system upgrade." sudo pacman -Sy --needed --noconfirm archlinux-keyring else - echo "[oh-my-zsh] Arch Linux PGP Keyring is up to date." + echo " Arch Linux PGP Keyring is up to date." + echo " Proceeding with full system upgrade." fi - echo "[oh-mh-zsh] Proceeding with full system upgrade." if (( $+commands[yay] )); then yay -Syu elif (( $+commands[trizen] )); then From b4f9698733d7b29cc495e649e26fd6c3a5dcfcae Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Tue, 11 Apr 2023 01:41:00 -0700 Subject: [PATCH 07/47] docs(ssh-agent): macOS and p10k advices (#11612) --- plugins/ssh-agent/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index fa6a996d4..8c118e65b 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -99,6 +99,33 @@ ssh-add -K -c -a /run/user/1000/ssh-auth For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`. +### Powerline 10k specific settings + +Powerline10k has an instant prompt setting that doesn't like when this plugin +writes to the console. Consider using the following settings if you're using +p10k (documented above): + +``` +zstyle :omz:plugins:ssh-agent quiet yes +zstyle :omz:plugins:ssh-agent lazy yes +``` + +### macOS specific settings + +macOS supports using passphrases stored in the keychain when adding identities +to the ssh-agent. + +``` +ssh-add --apple-use-keychain ~/.ssh/id_rsa ... +``` + + +This plugin can be configured to use the keychain when loading using the following: + +``` +zstyle :omz:plugins:ssh-agent ssh-add-args --apple-load-keychain +``` + ## Credits Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html From bd5ebba834c53e730671d9d24d93eb98b812a579 Mon Sep 17 00:00:00 2001 From: Eddie Romanov <81505200+SnoopDraugg@users.noreply.github.com> Date: Sun, 16 Apr 2023 03:49:04 -0400 Subject: [PATCH 08/47] feat(pipenv): add pupd alias (#11616) --- plugins/pipenv/README.md | 1 + plugins/pipenv/pipenv.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md index ab1c1e442..4329feb32 100644 --- a/plugins/pipenv/README.md +++ b/plugins/pipenv/README.md @@ -23,6 +23,7 @@ This plugin provides some features to simplify the use of Pipenv while working o - `psh` is aliased to `pipenv shell` - `psy` is aliased to `pipenv sync` - `pu` is aliased to `pipenv uninstall` + - `pupd` is aliased to `pipenv update` - `pwh` is aliased to `pipenv --where` - `pvenv` is aliased to `pipenv --venv` - `ppy` is aliased to `pipenv --py` diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 244bd6b7c..22d1a3131 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -47,6 +47,7 @@ alias prun="pipenv run" alias psh="pipenv shell" alias psy="pipenv sync" alias pu="pipenv uninstall" +alias pupd="pipenv update" alias pwh="pipenv --where" alias pvenv="pipenv --venv" alias ppy="pipenv --py" From d889eca72633b7a66d6c832736a5460c5f1a1833 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 17 Apr 2023 20:09:30 +0200 Subject: [PATCH 09/47] fix(check_for_upgrade): update properly `LAST_EPOCH` Fixes #11617 --- tools/check_for_upgrade.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 81c371b3f..3210e4375 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -180,6 +180,7 @@ function has_typed_input() { # Check if there are updates available before proceeding if ! is_update_available; then + update_last_updated_file return fi From 673b9fc3317d48a169fe612575186b3eb1a42a13 Mon Sep 17 00:00:00 2001 From: Mark Keisler Date: Tue, 18 Apr 2023 03:36:07 -0500 Subject: [PATCH 10/47] feat(aws)!: improve `aws_change_access_key` (#11378) BREAKING CHANGE: This commit removes compatibility for `aws` cli v1. Now only v2 is supported. --- plugins/aws/README.md | 11 ++++++----- plugins/aws/aws.plugin.zsh | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 846bf1414..54bc7a44d 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -1,7 +1,8 @@ # aws -This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html) +This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html) and a few utilities to manage AWS profiles/regions and display them in the prompt. +[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported. To use it, add `aws` to the plugins array in your zshrc file. @@ -12,9 +13,9 @@ plugins=(... aws) ## Plugin commands * `asp []`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. - It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`. + It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`. 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. +* `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. @@ -65,7 +66,7 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control Source profile credentials in `~/.aws/credentials`: -``` +```ini [source-profile-name] aws_access_key_id = ... aws_secret_access_key = ... @@ -73,7 +74,7 @@ aws_secret_access_key = ... Role configuration in `~/.aws/config`: -``` +```ini [profile source-profile-name] mfa_serial = arn:aws:iam::111111111111:mfa/myuser region = us-east-1 diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index a379eaa18..d45abba57 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -160,14 +160,39 @@ function aws_change_access_key() { return 1 fi - echo "Insert the credentials when asked." - asp "$1" || return 1 - AWS_PAGER="" aws iam create-access-key - AWS_PAGER="" aws configure --profile "$1" + local profile="$1" + # Get current access key + local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)" - echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`" + asp "$profile" || return 1 + echo "Generating a new access key pair for you now." + if aws --no-cli-pager iam create-access-key; then + echo "Insert the newly generated credentials when asked." + aws --no-cli-pager configure --profile $profile + else + echo "Current access keys:" + aws --no-cli-pager iam list-access-keys + echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`" + return 1 + fi + + read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? " + case $yn in + [Yy]*) + echo -n "\nDisabling access key ${original_aws_access_key_id}..." + if aws --no-cli-pager update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then + echo "done." + else + echo "\nFailed to disable ${original_aws_access_key_id} key." + fi + ;; + *) + echo "" + ;; + esac + echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`" echo "Your current keys are:" - AWS_PAGER="" aws iam list-access-keys + aws --no-cli-pager iam list-access-keys } function aws_regions() { From 9139d30ca30f8f687cc21121ed9b4f5238bc5260 Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Wed, 19 Apr 2023 22:46:10 +0900 Subject: [PATCH 11/47] feat(aws): allow more customisation in prompt function (#11619) --- plugins/aws/README.md | 2 ++ plugins/aws/aws.plugin.zsh | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 54bc7a44d..9e1e055b8 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -58,6 +58,8 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control * ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`. +* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space). + ## Configuration [Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d45abba57..0da91bc22 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -223,13 +223,16 @@ compctl -K _aws_profiles asp acp aws_change_access_key function aws_prompt_info() { local _aws_to_show local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}" + if [[ -n $AWS_PROFILE ]];then - _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX:=}" + _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX=""}" fi + if [[ -n $AWS_REGION ]]; then - [[ -n $AWS_PROFILE ]] && _aws_to_show+=" " - _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX:=}" + [[ -n $AWS_PROFILE ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=' '}" + _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX=""}" fi + echo "$_aws_to_show" } From 18c837b136a9591117ef059eb8266c490d5eeee1 Mon Sep 17 00:00:00 2001 From: Erin Schlarb Date: Thu, 20 Apr 2023 13:30:49 +0200 Subject: [PATCH 12/47] fix(dirhistory): run properly if `ksh_arrays` is set (#11630) --- plugins/dirhistory/dirhistory.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 7021fc03a..8d67c6188 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -19,15 +19,17 @@ export DIRHISTORY_SIZE=30 # Returns the element if the array was not empty, # otherwise returns empty string. function pop_past() { - typeset -g $1="${dirhistory_past[$#dirhistory_past]}" + setopt localoptions no_ksh_arrays if [[ $#dirhistory_past -gt 0 ]]; then + typeset -g $1="${dirhistory_past[$#dirhistory_past]}" dirhistory_past[$#dirhistory_past]=() fi } function pop_future() { - typeset -g $1="${dirhistory_future[$#dirhistory_future]}" + setopt localoptions no_ksh_arrays if [[ $#dirhistory_future -gt 0 ]]; then + typeset -g $1="${dirhistory_future[$#dirhistory_future]}" dirhistory_future[$#dirhistory_future]=() fi } @@ -35,6 +37,7 @@ function pop_future() { # Push a new element onto the end of dirhistory_past. If the size of the array # is >= DIRHISTORY_SIZE, the array is shifted function push_past() { + setopt localoptions no_ksh_arrays if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then shift dirhistory_past fi @@ -44,6 +47,7 @@ function push_past() { } function push_future() { + setopt localoptions no_ksh_arrays if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then shift dirhistory_future fi From 5b11e70a9617c6e248fd6947e84016bd8c37028e Mon Sep 17 00:00:00 2001 From: Erin Schlarb Date: Thu, 20 Apr 2023 13:32:32 +0200 Subject: [PATCH 13/47] fix(cli): execute as expected if `ksh_arrays` is set (#11629) --- lib/cli.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index ba3e39eb5..561c1b98b 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -11,7 +11,7 @@ function omz { # Subcommand functions start with _ so that they don't # appear as completion entries when looking for `omz` - (( $+functions[_omz::$command] )) || { + (( ${+functions[_omz::$command]} )) || { _omz::help return 1 } From 91c7ed45a312a71b7d3b856228047ddcd51d4651 Mon Sep 17 00:00:00 2001 From: Nathanial Spearing Date: Thu, 20 Apr 2023 07:42:47 -0400 Subject: [PATCH 14/47] feat(npm): add `npmrd` alias (#11627) --- plugins/npm/README.md | 1 + plugins/npm/npm.plugin.zsh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/npm/README.md b/plugins/npm/README.md index 8eafc6d61..420dd710a 100644 --- a/plugins/npm/README.md +++ b/plugins/npm/README.md @@ -29,6 +29,7 @@ plugins=(... npm) | `npmI` | `npm init` | Run npm init | | `npmi` | `npm info` | Run npm info | | `npmSe` | `npm search` | Run npm search | +| `npmrd` | `npm run dev` | Run npm run dev | ## `npm install` / `npm uninstall` toggle diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index e0dcbf142..3cba18f6c 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -70,6 +70,9 @@ alias npmi="npm info" # Run npm search alias npmSe="npm search" +# Run npm run dev +alias npmrd="npm run dev" + npm_toggle_install_uninstall() { # Look up to the previous 2 history commands local line From 07454029bd67239ce42aaa68b427fbbe8e428e7d Mon Sep 17 00:00:00 2001 From: Andrew Xie <62098008+axieax@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:59:58 +1000 Subject: [PATCH 15/47] feat(starship): create plugin (#10947) Co-authored-by: Carlo Sala --- .github/CODEOWNERS | 1 + plugins/starship/README.md | 21 +++++++++++++++++++++ plugins/starship/starship.plugin.zsh | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 plugins/starship/README.md create mode 100644 plugins/starship/starship.plugin.zsh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6668cd7ce..599b765ca 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -9,3 +9,4 @@ plugins/shell-proxy/ @septs plugins/universalarchive/ @Konfekt plugins/wp-cli/ @joshmedeski plugins/zoxide/ @ajeetdsouza +plugins/starship/ @axieax diff --git a/plugins/starship/README.md b/plugins/starship/README.md new file mode 100644 index 000000000..0e66c5294 --- /dev/null +++ b/plugins/starship/README.md @@ -0,0 +1,21 @@ +# starship plugin + +Initializes [starship prompt](https://starship.rs) - a minimal, blazing-fast and infinitely customizable cross-shell prompt. + +[Demo](https://user-images.githubusercontent.com/62098008/169764279-50b48262-9506-4651-ba89-f6611a88ebf0.mp4) + +[External repository](https://github.com/axieax/zsh-starship) for this zsh plugin. + +# Installation + +**Note:** you have to [install starship](https://starship.rs/guide/#%F0%9F%9A%80-installation) first. + +## [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh) + +Add `starship` to the plugins array in your `.zshrc` file: + +```zsh +plugins=(... starship) +``` + +## ⚠️ ENABLING THIS PLUGIN WILL UNSET YOUR ZSH_THEME VARIABLE diff --git a/plugins/starship/starship.plugin.zsh b/plugins/starship/starship.plugin.zsh new file mode 100644 index 000000000..8c5d9135e --- /dev/null +++ b/plugins/starship/starship.plugin.zsh @@ -0,0 +1,8 @@ +# ignore oh-my-zsh theme +unset ZSH_THEME + +if (( $+commands[starship] )); then + eval "$(starship init zsh)" +else + echo '[oh-my-zsh] starship not found, please install it from https://starship.rs' +fi From 5d3e86e2a48adf7a308773f8f1b725d187c7c5ef Mon Sep 17 00:00:00 2001 From: Miguel Sempere Date: Fri, 21 Apr 2023 08:15:31 +0100 Subject: [PATCH 16/47] feat(dbt): create plugin (#11635) Co-authored-by: Carlo Sala --- .github/CODEOWNERS | 1 + plugins/dbt/README.md | 29 +++++++++++++++++++++++++++++ plugins/dbt/dbt.plugin.zsh | 23 +++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 plugins/dbt/README.md create mode 100644 plugins/dbt/dbt.plugin.zsh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 599b765ca..0c5f3acee 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,3 +10,4 @@ plugins/universalarchive/ @Konfekt plugins/wp-cli/ @joshmedeski plugins/zoxide/ @ajeetdsouza plugins/starship/ @axieax +plugins/dbt/ @msempere diff --git a/plugins/dbt/README.md b/plugins/dbt/README.md new file mode 100644 index 000000000..e05d79cc3 --- /dev/null +++ b/plugins/dbt/README.md @@ -0,0 +1,29 @@ +# dbt plugin + +## Introduction + +The `dbt plugin` adds several aliases for useful [dbt](https://docs.getdbt.com/) commands and +[aliases](#aliases). + +To use it, add `dbt` to the plugins array of your zshrc file: + +``` +plugins=(... dbt) +``` + +## Aliases + +| Alias | Command | Description | +| ------ | ------------------------------------------------ | ---------------------------------------------------- | +| dbtlm | `dbt ls -s state:modified` | List modified models only | +| dbtrm | `dbt run -s state:modified` | Run modified models only | +| dbttm | `dbt test -m state:modified` | Test modified models only | +| dbtrtm | `dbtrm && dbttm` | Run and test modified models only | +| dbtrs | `dbt clean; dbt deps; dbt seed` | Re-seed data | +| dbtfrt | `dbtrs; dbt run --full-refresh; dbt test` | Perform a full fresh run with tests | +| dbtcds | `dbt docs generate; dbt docs serve` | Generate docs without compiling | +| dbtds | `dbt docs generate --no-compile; dbt docs serve` | Generate and serve docs skipping doc. re-compilation | + +## Maintainer + +### [msempere](https://github.com/msempere) diff --git a/plugins/dbt/dbt.plugin.zsh b/plugins/dbt/dbt.plugin.zsh new file mode 100644 index 000000000..6fcc2eecf --- /dev/null +++ b/plugins/dbt/dbt.plugin.zsh @@ -0,0 +1,23 @@ +# list modified models only +alias dbtlm="dbt ls -s state:modified" + +# run modified models only +alias dbtrm="dbt run -s state:modified" + +# test modified models only +alias dbttm="dbt test -m state:modified" + +# run and test modified models only +alias dbtrtm="dbtrm && dbttm" + +# re-seed data +alias dbtrs="dbt clean; dbt deps; dbt seed" + +# perform a full fresh run with tests +alias dbtfrt="dbtrs; dbt run --full-refresh; dbt test" + +# generate and serve docs +alias dbtcds="dbt docs generate; dbt docs serve" + +# generate and serve docs skipping doc. re-compilation +alias dbtds="dbt docs generate --no-compile; dbt docs serve" From 343c78ae91ff03ea66517b1d69b25fa262ce5408 Mon Sep 17 00:00:00 2001 From: Idan Fishman Date: Thu, 27 Apr 2023 11:49:26 +0200 Subject: [PATCH 17/47] fix(aws): set properly set divider to space Closes #11649 Co-authored-by: Carlo Sala --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 0da91bc22..a437dc8e8 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -229,7 +229,7 @@ function aws_prompt_info() { fi if [[ -n $AWS_REGION ]]; then - [[ -n $AWS_PROFILE ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=' '}" + [[ -n $AWS_PROFILE ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}" _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX=""}" fi From 65699912be974d36b732b63e32c3b9428d23ace8 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 27 Apr 2023 09:57:44 +0200 Subject: [PATCH 18/47] fix(azure): recognize properly linuxbrew Closes #11644 --- plugins/azure/azure.plugin.zsh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh index 8fec3c1f7..22fbea80f 100644 --- a/plugins/azure/azure.plugin.zsh +++ b/plugins/azure/azure.plugin.zsh @@ -31,11 +31,9 @@ function _az-homebrew-installed() { # check if Homebrew is installed (( $+commands[brew] )) || return 1 - # speculatively check default brew prefix - if [[ -d /usr/local ]]; then - _brew_prefix=/usr/local - elif [[ -d /opt/homebrew ]]; then - _brew_prefix=/opt/homebrew + # if so, we assume it's default way to install brew + if [[ ${commands[brew]:t2} == bin/brew ]]; then + _brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew 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 From 5fc1118fd240a0d87ad022d36f48cb31d869ab2e Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 27 Apr 2023 19:42:55 +0200 Subject: [PATCH 19/47] chore(azure): fix typo --- plugins/azure/azure.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh index 22fbea80f..b33b0f805 100644 --- a/plugins/azure/azure.plugin.zsh +++ b/plugins/azure/azure.plugin.zsh @@ -1,4 +1,4 @@ -# AZ Get Subscritions +# AZ Get Subscriptions function azgs() { az account show --output tsv --query 'name' 2>/dev/null } From 2e7a247cab663fbc0aafdefa15bf10eb4dd64563 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 28 Apr 2023 09:05:36 +0200 Subject: [PATCH 20/47] feat(z): update to latest upstream version Mirror of https://github.com/agkozak/zsh-z/commit/6bfe418332866d15373392164df11b4fbec2083f Closes #11652 Co-authored-by: Carlo Sala --- plugins/z/LICENSE | 2 +- plugins/z/MANUAL.md | 21 ++++++++++-- plugins/z/_z | 2 +- plugins/z/img/mit_license.svg | 1 + plugins/z/img/zsh_4.3.11_plus.svg | 1 + plugins/z/z.plugin.zsh | 54 ++++++++++++++++++++++++------- 6 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 plugins/z/img/mit_license.svg create mode 100644 plugins/z/img/zsh_4.3.11_plus.svg diff --git a/plugins/z/LICENSE b/plugins/z/LICENSE index d1cca7ae5..6af13b9e0 100644 --- a/plugins/z/LICENSE +++ b/plugins/z/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2022 Alexandros Kozak +Copyright (c) 2018-2023 Alexandros Kozak Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md index dcca3c452..d367c3026 100644 --- a/plugins/z/MANUAL.md +++ b/plugins/z/MANUAL.md @@ -1,5 +1,9 @@ # Zsh-z +[![MIT License](img/mit_license.svg)](https://opensource.org/licenses/MIT) +![Zsh version 4.3.11 and higher](img/zsh_4.3.11_plus.svg) +[![GitHub stars](https://img.shields.io/github/stars/agkozak/zsh-z.svg)](https://github.com/agkozak/zsh-z/stargazers) + Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`. Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`. @@ -28,6 +32,10 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
Here are the latest features and updates. +- April 27, 2023 + + Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt). +- January 27, 2023 + + If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3). - June 29, 2022 + Zsh-z is less likely to leave temporary files sitting around (props @mafredri). - June 27, 2022 @@ -118,13 +126,19 @@ Add the line to your `.zshrc`, somewhere above the line that says `antigen apply`. -### For [oh-my-zsh](http://ohmyz.sh/) users +### For [Oh My Zsh](http://ohmyz.sh/) users -Execute the following command: +Zsh-z is now included as part of Oh My Zsh! As long as you are using an up-to-date installation of Oh My Zsh, you can activate Zsh-z simply by adding `z` to your `plugins` array in your `.zshrc`, e.g., + + plugins=( git z ) + +It is as simple as that. + +If, however, you prefer always to use the latest version of Zsh-z from the `agkozak/zsh-z` repo, you may install it thus: git clone https://github.com/agkozak/zsh-z ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z -and add `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`. +and activate it by adding `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`. ### For [prezto](https://github.com/sorin-ionescu/prezto) users @@ -246,6 +260,7 @@ to install `zsh-z`. Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`). * `ZSHZ_CMD` changes the command name (default: `z`) +* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`) * `ZSHZ_COMPLETION` can be `'frecent'` (default) or `'legacy'`, depending on whether you want your completion results sorted according to frecency or simply sorted alphabetically * `ZSHZ_DATA` changes the database file (default: `~/.z`) * `ZSHZ_ECHO` displays the new path name when changing directories (default: `0`) diff --git a/plugins/z/_z b/plugins/z/_z index 9891a52ed..a493f35ba 100644 --- a/plugins/z/_z +++ b/plugins/z/_z @@ -5,7 +5,7 @@ # # https://github.com/agkozak/zsh-z # -# Copyright (c) 2018-2022 Alexandros Kozak +# Copyright (c) 2018-2023 Alexandros Kozak # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/plugins/z/img/mit_license.svg b/plugins/z/img/mit_license.svg new file mode 100644 index 000000000..1c02079d7 --- /dev/null +++ b/plugins/z/img/mit_license.svg @@ -0,0 +1 @@ +licenselicenseMITMIT \ No newline at end of file diff --git a/plugins/z/img/zsh_4.3.11_plus.svg b/plugins/z/img/zsh_4.3.11_plus.svg new file mode 100644 index 000000000..f46d947d0 --- /dev/null +++ b/plugins/z/img/zsh_4.3.11_plus.svg @@ -0,0 +1 @@ +zshzsh4.3.11+4.3.11+ \ No newline at end of file diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh index 209edfea7..60a630624 100644 --- a/plugins/z/z.plugin.zsh +++ b/plugins/z/z.plugin.zsh @@ -4,7 +4,7 @@ # # https://github.com/agkozak/zsh-z # -# Copyright (c) 2018-2022 Alexandros Kozak +# Copyright (c) 2018-2023 Alexandros Kozak # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -52,6 +52,7 @@ # ZSHZ_CASE -> if `ignore', pattern matching is case-insensitive; if `smart', # pattern matching is case-insensitive only when the pattern is all # lowercase +# ZSHZ_CD -> the directory-changing command that is used (default: builtin cd) # ZSHZ_CMD -> name of command (default: z) # ZSHZ_COMPLETION -> completion method (default: 'frecent'; 'legacy' for # alphabetic sorting) @@ -129,6 +130,7 @@ is-at-least 5.3.0 && ZSHZ[PRINTV]=1 # Globals: # ZSHZ # ZSHZ_CASE +# ZSHZ_CD # ZSHZ_COMPLETION # ZSHZ_DATA # ZSHZ_DEBUG @@ -149,9 +151,19 @@ zshz() { local REPLY local -a lines - # Allow the user to specify the datafile name in $ZSHZ_DATA (default: ~/.z) + # Allow the user to specify a custom datafile in $ZSHZ_DATA (or legacy $_Z_DATA) + local custom_datafile="${ZSHZ_DATA:-$_Z_DATA}" + + # If a datafile was provided as a standalone file without a directory path + # print a warning and exit + if [[ -n ${custom_datafile} && ${custom_datafile} != */* ]]; then + print "ERROR: You configured a custom Zsh-z datafile (${custom_datafile}), but have not specified its directory." >&2 + exit + fi + + # If the user specified a datafile, use that or default to ~/.z # If the datafile is a symlink, it gets dereferenced - local datafile=${${ZSHZ_DATA:-${_Z_DATA:-${HOME}/.z}}:A} + local datafile=${${custom_datafile:-$HOME/.z}:A} # If the datafile is a directory, print a warning and exit if [[ -d $datafile ]]; then @@ -161,7 +173,7 @@ zshz() { # Make sure that the datafile exists before attempting to read it or lock it # for writing - [[ -f $datafile ]] || touch "$datafile" + [[ -f $datafile ]] || { mkdir -p "${datafile:h}" && touch "$datafile" } # Bail if we don't own the datafile and $ZSHZ_OWNER is not set [[ -z ${ZSHZ_OWNER:-${_Z_OWNER}} && -f $datafile && ! -O $datafile ]] && @@ -620,7 +632,7 @@ zshz() { *) # Frecency routine (( dx = EPOCHSECONDS - time_field )) - rank=$(( 10000 * rank_field * (3.75/((0.0001 * dx + 1) + 0.25)) )) + rank=$(( 10000 * rank_field * (3.75/( (0.0001 * dx + 1) + 0.25)) )) ;; esac @@ -756,6 +768,26 @@ zshz() { [[ $output_format != 'completion' ]] && output_format='list' } + ######################################################### + # Allow the user to specify directory-changing command + # using $ZSHZ_CD (default: builtin cd). + # + # Globals: + # ZSHZ_CD + # + # Arguments: + # $* Path + ######################################################### + zshz_cd() { + setopt LOCAL_OPTIONS NO_WARN_CREATE_GLOBAL + + if [[ -z $ZSHZ_CD ]]; then + builtin cd "$*" + else + ${=ZSHZ_CD} "$*" + fi + } + ######################################################### # If $ZSHZ_ECHO == 1, display paths as you jump to them. # If it is also the case that $ZSHZ_TILDE == 1, display @@ -773,7 +805,7 @@ zshz() { if [[ ${@: -1} == /* ]] && (( ! $+opts[-e] && ! $+opts[-l] )); then # cd if possible; echo the new path if $ZSHZ_ECHO == 1 - [[ -d ${@: -1} ]] && builtin cd ${@: -1} && _zshz_echo && return + [[ -d ${@: -1} ]] && zshz_cd ${@: -1} && _zshz_echo && return fi # With option -c, make sure query string matches beginning of matches; @@ -830,12 +862,12 @@ zshz() { print -- "$cd" else # cd if possible; echo the new path if $ZSHZ_ECHO == 1 - [[ -d $cd ]] && builtin cd "$cd" && _zshz_echo + [[ -d $cd ]] && zshz_cd "$cd" && _zshz_echo fi else # if $req is a valid path, cd to it; echo the new path if $ZSHZ_ECHO == 1 if ! (( $+opts[-e] || $+opts[-l] )) && [[ -d $req ]]; then - builtin cd "$req" && _zshz_echo + zshz_cd "$req" && _zshz_echo else return $ret2 fi @@ -900,9 +932,9 @@ add-zsh-hook chpwd _zshz_chpwd ############################################################ # Standarized $0 handling -# (See https://github.com/agkozak/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc) -0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}} -0=${${(M)0:#/*}:-$PWD/$0} +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" (( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" ) From b22593cf179bae479ab32700c5a7b94d3053762d Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 1 May 2023 22:21:01 +0200 Subject: [PATCH 21/47] fix(init): avoid overwriting existing aliases Fix regression introduced in #11550. If an existing alias was present in the moment of sourcing, and oh-my-zsh aliases were disabled for that file, it'd be overwritten aswell. See #11658. --- oh-my-zsh.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index e047d4834..a577c1f41 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -159,10 +159,10 @@ _omz_source() { zstyle -T ":omz:${context}" aliases || disable_aliases=1 # Back up alias names prior to sourcing - local -a aliases_pre galiases_pre + local -A aliases_pre galiases_pre if (( disable_aliases )); then - aliases_pre=("${(@k)aliases}") - galiases_pre=("${(@k)galiases}") + aliases_pre=("${(@kv)aliases}") + galiases_pre=("${(@kv)galiases}") fi # Source file from $ZSH_CUSTOM if it exists, otherwise from $ZSH @@ -174,10 +174,16 @@ _omz_source() { # Unset all aliases that don't appear in the backed up list of aliases if (( disable_aliases )); then - local -a disabled - # ${var:|array} gets the list of items in var not in array - disabled=("${(@k)aliases:|aliases_pre}" "${(@k)galiases:|galiases_pre}") - (( $#disabled == 0 )) || unalias "${(@)disabled}" + if (( #aliases_pre )); then + aliases=("${(@kv)aliases_pre}") + else + (( #aliases )) && unalias "${(@k)aliases}" + fi + if (( #galiases_pre )); then + galiases=("${(@kv)galiases_pre}") + else + (( #galiases )) && unalias "${(@k)galiases}" + fi fi } From 693e3dcc447b5d6fa611eea43166ea2b4e0ed877 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 2 May 2023 10:03:24 +0200 Subject: [PATCH 22/47] fix(apple): replace deprecated nerdfonts icon --- themes/apple.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/apple.zsh-theme b/themes/apple.zsh-theme index 0c183258e..65a2b80fe 100644 --- a/themes/apple.zsh-theme +++ b/themes/apple.zsh-theme @@ -1,5 +1,5 @@ function toon { - echo -n "" + echo -n "󰐀" } autoload -Uz vcs_info From dab09cc0eec220f5c1a541ccb75449c62c20bdb4 Mon Sep 17 00:00:00 2001 From: Oleg Grigoriev Date: Tue, 2 May 2023 13:27:57 +0300 Subject: [PATCH 23/47] feat(rake-fast): show task descriptions in autocomplete (#11653) --- plugins/rake-fast/rake-fast.plugin.zsh | 39 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh index 19dab154b..86e5ed586 100644 --- a/plugins/rake-fast/rake-fast.plugin.zsh +++ b/plugins/rake-fast/rake-fast.plugin.zsh @@ -1,5 +1,28 @@ +# The version of the format of .rake_tasks. If the output of _rake_generate +# changes, incrementing this number will force it to regenerate +_rake_tasks_version=2 + _rake_does_task_list_need_generating () { - [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] || { _is_rails_app && _tasks_changed } + _rake_tasks_missing || _rake_tasks_version_changed || _rakefile_has_changes || { _is_rails_app && _tasks_changed } +} + +_rake_tasks_missing () { + [[ ! -f .rake_tasks ]] +} + +_rake_tasks_version_changed () { + local -a file_version + file_version=`head -n 1 .rake_tasks | sed "s/^version\://"` + + if ! [[ $file_version =~ '^[0-9]*$' ]]; then + return true + fi + + [[ $file_version -ne $_rake_tasks_version ]] +} + +_rakefile_has_changes () { + [[ Rakefile -nt .rake_tasks ]] } _is_rails_app () { @@ -20,7 +43,14 @@ _tasks_changed () { } _rake_generate () { - rake --silent --tasks | cut -d " " -f 2 | sed 's/\[.*\]//g' > .rake_tasks + echo "version:$_rake_tasks_version" > .rake_tasks + + rake --silent --tasks --all \ + | sed "s/^rake //" | sed "s/\:/\\\:/g" \ + | sed "s/\[[^]]*\]//g" \ + | sed "s/ *# /\:/" \ + | sed "s/\:$//" \ + >> .rake_tasks } _rake () { @@ -29,7 +59,10 @@ _rake () { echo "\nGenerating .rake_tasks..." >&2 _rake_generate fi - compadd $(cat .rake_tasks) + local -a rake_options + rake_options=("${(@f)$(cat .rake_tasks)}") + shift rake_options + _describe 'rake tasks' rake_options fi } compdef _rake rake From 85fdbfe21692a3fa7bdd7bc509163e23fb385279 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 3 May 2023 11:17:47 +0200 Subject: [PATCH 24/47] fix(apple): go back to previous icon Turns out that is a reserved unicode code that is Apple logo in Apple systems. Nerd fonts was overwritting that code to other stuff in v2 and that's why I thought it needed to be replaced. Closes #11665 This reverts commit 693e3dcc447b5d6fa611eea43166ea2b4e0ed877. --- themes/apple.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/apple.zsh-theme b/themes/apple.zsh-theme index 65a2b80fe..0c183258e 100644 --- a/themes/apple.zsh-theme +++ b/themes/apple.zsh-theme @@ -1,5 +1,5 @@ function toon { - echo -n "󰐀" + echo -n "" } autoload -Uz vcs_info From 5a3f565e7d4371db92ba574f231b396c2c8c9a19 Mon Sep 17 00:00:00 2001 From: kang <1115610574@qq.com> Date: Wed, 3 May 2023 23:48:37 +0800 Subject: [PATCH 25/47] feat(deno): add `dru` alias for `--unstable` (#11667) --- plugins/deno/README.md | 27 ++++++++++++++------------- plugins/deno/deno.plugin.zsh | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/deno/README.md b/plugins/deno/README.md index 691318397..38f9f2033 100644 --- a/plugins/deno/README.md +++ b/plugins/deno/README.md @@ -4,16 +4,17 @@ This plugin sets up completion and aliases for [Deno](https://deno.land). ## Aliases -| Alias | Full command | -| ----- | ---------------- | -| db | deno bundle | -| dc | deno compile | -| dca | deno cache | -| dfmt | deno fmt | -| dh | deno help | -| dli | deno lint | -| drn | deno run | -| drA | deno run -A | -| drw | deno run --watch | -| dts | deno test | -| dup | deno upgrade | +| Alias | Full command | +| ----- | ------------------- | +| db | deno bundle | +| dc | deno compile | +| dca | deno cache | +| dfmt | deno fmt | +| dh | deno help | +| dli | deno lint | +| drn | deno run | +| drA | deno run -A | +| drw | deno run --watch | +| dru | deno run --unstable | +| dts | deno test | +| dup | deno upgrade | diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 7708f84df..bf97d6f03 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -8,6 +8,7 @@ alias dli='deno lint' alias drn='deno run' alias drA='deno run -A' alias drw='deno run --watch' +alias dru='deno run --unstable' alias dts='deno test' alias dup='deno upgrade' From c5208867f1eb46f722e040b239150817abec87a6 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 2 May 2023 12:41:01 +0200 Subject: [PATCH 26/47] feat(theme-and-appearance): allow disabling gnu-ls in bsd To disable gnu-ls (`gls`) even if it's installed in freeBSD and macOS you can set it up with: ```zsh zstyle ':omz:lib:theme-and-appearance' gnu-ls no ``` Closes #11647 --- README.md | 13 +++++++++++++ lib/theme-and-appearance.zsh | 36 +++++++++++++++++------------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 556d4c8c5..650fb00ea 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi - [Manual Installation](#manual-installation) - [Installation Problems](#installation-problems) - [Custom Plugins and Themes](#custom-plugins-and-themes) + - [Disable GNU ls in macOS and freeBSD systems](#disable-gnu-ls) - [Skip aliases](#skip-aliases) - [Getting Updates](#getting-updates) - [Updates verbosity](#updates-verbosity) @@ -278,6 +279,18 @@ 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/`. +### Disable GNU ls in macOS and freeBSD systems + + + +The default behaviour in Oh My Zsh is to use GNU `ls` even in macOS and freeBSD systems if it's installed (as +`gls` command) when enabling colorized `ls` in `lib/theme-and-appearance.zsh`. If you want to disable this +behaviour you can use zstyle-based config before sourcing `oh-my-zsh.sh`: + +```zsh +zstyle ':omz:lib:theme-and-appearance' gnu-ls no +``` + ### Skip aliases diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index d8859b04c..96bdb00e5 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -20,10 +20,25 @@ if command diff --color /dev/null{,} &>/dev/null; then } fi - # Don't set ls coloring if disabled [[ "$DISABLE_LS_COLORS" != true ]] || return 0 +# Default coloring for BSD-based ls +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +# 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=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 + function test-ls-args { local cmd="$1" # ls, gls, colorls, ... local args="${@[2,-1]}" # arguments except the first one @@ -50,7 +65,7 @@ case "$OSTYPE" in 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" ]] \ + zstyle -T ':omz:lib:theme-and-appearance' gnu-ls \ && test-ls-args gls --color \ && alias ls='gls --color=tty' ;; @@ -64,20 +79,3 @@ case "$OSTYPE" in esac unfunction test-ls-args - - -# Default coloring for BSD-based ls -export LSCOLORS="Gxfxcxdxbxegedabagacad" - -# 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=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 From 017e288560ef7bdfb8835516d6b3b77bbdcdde6c Mon Sep 17 00:00:00 2001 From: Mark Keisler Date: Sat, 6 May 2023 06:40:06 -0500 Subject: [PATCH 27/47] fix(aws): correct access key disable command (#11671) --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index a437dc8e8..b2415b737 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -180,7 +180,7 @@ function aws_change_access_key() { case $yn in [Yy]*) echo -n "\nDisabling access key ${original_aws_access_key_id}..." - if aws --no-cli-pager update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then + if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then echo "done." else echo "\nFailed to disable ${original_aws_access_key_id} key." From dcff7a7f0854591ee1b4f25266f292ec1b1904eb Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 9 May 2023 12:05:15 +0200 Subject: [PATCH 28/47] fix(theme-and-appearance): make bsd `ls` to be default --- 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 96bdb00e5..585e969d8 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -65,7 +65,7 @@ case "$OSTYPE" in 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 - zstyle -T ':omz:lib:theme-and-appearance' gnu-ls \ + zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \ && test-ls-args gls --color \ && alias ls='gls --color=tty' ;; From aaf83d37aa1cc5ed2cb96dd29328502003a70848 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 9 May 2023 12:10:05 +0200 Subject: [PATCH 29/47] docs(theme-and-appearance): reflect properly dcff7a7 changes --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 650fb00ea..2249b49dd 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi - [Manual Installation](#manual-installation) - [Installation Problems](#installation-problems) - [Custom Plugins and Themes](#custom-plugins-and-themes) - - [Disable GNU ls in macOS and freeBSD systems](#disable-gnu-ls) + - [Enable GNU ls in macOS and freeBSD systems](#enable-gnu-ls) - [Skip aliases](#skip-aliases) - [Getting Updates](#getting-updates) - [Updates verbosity](#updates-verbosity) @@ -279,18 +279,20 @@ 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/`. -### Disable GNU ls in macOS and freeBSD systems +### Enable GNU ls in macOS and freeBSD systems - + -The default behaviour in Oh My Zsh is to use GNU `ls` even in macOS and freeBSD systems if it's installed (as -`gls` command) when enabling colorized `ls` in `lib/theme-and-appearance.zsh`. If you want to disable this -behaviour you can use zstyle-based config before sourcing `oh-my-zsh.sh`: +The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD systems. If GNU `ls` is installed +(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before +sourcing `oh-my-zsh.sh`: ```zsh zstyle ':omz:lib:theme-and-appearance' gnu-ls no ``` +_Note: this is not compatible with `DISABLE_LS_COLORS=true`_ + ### Skip aliases From aab3bfff9f27a261dcd4cd4a2082a2ce3fff8c59 Mon Sep 17 00:00:00 2001 From: roodkcab Date: Tue, 9 May 2023 18:27:22 +0800 Subject: [PATCH 30/47] fix(robbyrussell) multiline command editing (#11681) Co-authored-by: chenshuoshi Closes #11680 --- themes/robbyrussell.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme index 2fd5f2cdc..173e6d579 100644 --- a/themes/robbyrussell.zsh-theme +++ b/themes/robbyrussell.zsh-theme @@ -1,5 +1,5 @@ -PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" -PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' +PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ ) %{$fg[cyan]%}%c%{$reset_color%}" +PROMPT+=' $(git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " From f01eea76da194fef6005f53a281b6f5a998db126 Mon Sep 17 00:00:00 2001 From: ZYX Date: Fri, 12 May 2023 02:42:30 -0700 Subject: [PATCH 31/47] fix(aws): use the correct variable to assert region is defined (#11691) --- plugins/aws/aws.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index b2415b737..c946515be 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -224,12 +224,12 @@ function aws_prompt_info() { local _aws_to_show local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}" - if [[ -n $AWS_PROFILE ]];then + if [[ -n "$AWS_PROFILE" ]];then _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX=""}" fi - if [[ -n $AWS_REGION ]]; then - [[ -n $AWS_PROFILE ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}" + if [[ -n "$region" ]]; then + [[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}" _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX=""}" fi From 7a030f6bd6c15259052c7007020cf3ecf8a3f299 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 15 May 2023 09:27:31 -0400 Subject: [PATCH 32/47] docs(pyenv): warn about pyenv init (#11692) --- plugins/pyenv/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index b9ee937b7..f1ca3d288 100644 --- a/plugins/pyenv/README.md +++ b/plugins/pyenv/README.md @@ -10,6 +10,14 @@ To use it, add `pyenv` to the plugins array in your zshrc file: plugins=(... pyenv) ``` +If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achived by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line: + +```zsh +export PYENV_ROOT="$HOME/.pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init --path)" +``` + ## Settings - `ZSH_PYENV_QUIET`: if set to `true`, the plugin will not print any messages if it From bfeeda1491b5366aa5798a86cf6f3621536b171c Mon Sep 17 00:00:00 2001 From: Craig Furman Date: Sun, 21 May 2023 11:47:38 +0100 Subject: [PATCH 33/47] docs(theme-and-appearance): fix gnu-ls snippet (#11701) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2249b49dd..a30595581 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,7 @@ The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD syste sourcing `oh-my-zsh.sh`: ```zsh -zstyle ':omz:lib:theme-and-appearance' gnu-ls no +zstyle ':omz:lib:theme-and-appearance' gnu-ls yes ``` _Note: this is not compatible with `DISABLE_LS_COLORS=true`_ From 3a01d7df82157a5f3aef01eab9a940e4cba2283a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 May 2023 19:58:26 +0200 Subject: [PATCH 34/47] fix(extract): fix extract dir naming conflicts Fixes #11642 --- plugins/extract/extract.plugin.zsh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 34c080653..ee1d38b3f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -27,12 +27,20 @@ EOF fi local success=0 - local extract_dir="${1:t:r}" local file="$1" full_path="${1:A}" + local extract_dir="${1:t:r}" + + # If there's a file or directory with the same name as the archive + # add a random string to the end of the extract directory + if [[ -e "$extract_dir" ]]; then + local rnd="${(L)"${$(( [##36]$RANDOM*$RANDOM ))}":1:5}" + extract_dir="${extract_dir}-${rnd}" + fi # Create an extraction directory based on the file name command mkdir -p "$extract_dir" builtin cd -q "$extract_dir" + echo "extract: extracting to $extract_dir" >&2 case "${file:l}" in (*.tar.gz|*.tgz) @@ -107,11 +115,13 @@ EOF if [[ "${content[1]:t}" == "$extract_dir" ]]; then # =(:) gives /tmp/zsh, with :t it gives zsh local tmp_dir==(:); tmp_dir="${tmp_dir:t}" - command mv -f "${content[1]}" "$tmp_dir" \ + command mv "${content[1]}" "$tmp_dir" \ && command rmdir "$extract_dir" \ - && command mv -f "$tmp_dir" "$extract_dir" - else - command mv -f "${content[1]}" . \ + && command mv "$tmp_dir" "$extract_dir" + # Otherwise, if the extracted folder name already exists in the current + # directory (because of a previous file / folder), keep the extract_dir + elif [[ ! -e "${content[1]:t}" ]]; then + command mv "${content[1]}" . \ && command rmdir "$extract_dir" fi elif [[ ${#content} -eq 0 ]]; then From b06663df23b2910a6e542dc114dc7adc2cdce22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 May 2023 20:14:32 +0200 Subject: [PATCH 35/47] feat(extract): add support for `.zlib` and `.exe` files (#11085) Fixes #11085 --- plugins/extract/README.md | 3 +++ plugins/extract/extract.plugin.zsh | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index ac4a8e197..c8d98b229 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -25,6 +25,7 @@ plugins=(... extract) | `cpio` | Cpio archive | | `deb` | Debian package | | `ear` | Enterprise Application aRchive | +| `exe` | Windows executable file | | `gz` | Gzip file | | `ipa` | iOS app package | | `ipsw` | iOS firmware file | @@ -52,9 +53,11 @@ plugins=(... extract) | `txz` | Tarball with lzma2 compression | | `tzst` | Tarball with zstd compression | | `war` | Web Application archive (Java-based) | +| `whl` | Python wheel file | | `xpi` | Mozilla XPI module file | | `xz` | LZMA2 archive | | `zip` | Zip archive | +| `zlib` | zlib archive | | `zst` | Zstandard file (zstd) | | `zpaq` | Zpaq file | diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index ee1d38b3f..b7a823c9f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -83,9 +83,10 @@ EOF builtin cd -q ../data; extract ../data.tar.* builtin cd -q ..; command rm *.tar.* debian-binary ;; (*.zst) unzstd "$full_path" ;; - (*.cab) cabextract "$full_path" ;; + (*.cab|*.exe) cabextract "$full_path" ;; (*.cpio|*.obscpio) cpio -idmvF "$full_path" ;; (*.zpaq) zpaq x "$full_path" ;; + (*.zlib) zlib-flate -uncompress < "$full_path" > "${file:r}" ;; (*) echo "extract: '$file' cannot be extracted" >&2 success=1 ;; From 444e715766c4a8b267dba82f3f0f562584d61adc Mon Sep 17 00:00:00 2001 From: rogarb <69053978+rogarb@users.noreply.github.com> Date: Mon, 22 May 2023 10:49:10 +0000 Subject: [PATCH 36/47] feat(bureau): ignore hidden git repos (#11707) The git_prompt_info() function in lib/git.zsh ignores git repos which contains a specific config key, allowing to effectively "hide" them from the prompt. Unfortunately, the bureau theme doesn't use the library function to build its prompt. This commit modifies the specific prompt generation function in the bureau theme in order to achieve the same behaviour. --- themes/bureau.zsh-theme | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 698aa2ff8..9943a0c8c 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -67,6 +67,12 @@ bureau_git_status() { } bureau_git_prompt() { + # ignore non git folders and hidden repos (adapted from lib/git.zsh) + if ! command git rev-parse --git-dir &> /dev/null \ + || [[ "$(command git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then + return + fi + # check git information local gitinfo=$(bureau_git_info) if [[ -z "$gitinfo" ]]; then From 902b79e635fedf4a12542d2ed8bd29665d3d281c Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 23 May 2023 08:43:47 +0200 Subject: [PATCH 37/47] fix(functions): use `command` env Closes #11709 --- lib/functions.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 1d85ea38a..a252d0a33 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -5,7 +5,7 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh" + command env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh" } function upgrade_oh_my_zsh() { From 1bbe4d8d2431b5ac06d7402b570431884786db58 Mon Sep 17 00:00:00 2001 From: Felipe Francisco Date: Tue, 23 May 2023 03:46:46 -0300 Subject: [PATCH 38/47] feat(half-life): add virtualenv prompt (#11708) --- themes/half-life.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme index c4d785126..2ad84ac83 100644 --- a/themes/half-life.zsh-theme +++ b/themes/half-life.zsh-theme @@ -89,5 +89,9 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} " ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_RVM_PROMPT_OPTIONS="v g" +# virtualenv prompt settings +ZSH_THEME_VIRTUALENV_PREFIX=" with%F{red} " +ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color%}" + setopt prompt_subst -PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} " +PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(virtualenv_prompt_info)\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} " From ec369bb38e873fa2e8954bc45bc192fdb0051313 Mon Sep 17 00:00:00 2001 From: rogarb <69053978+rogarb@users.noreply.github.com> Date: Wed, 24 May 2023 12:32:26 +0000 Subject: [PATCH 39/47] fix(bureau): properly display git stash info (#11711) --- themes/bureau.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 9943a0c8c..e87a594cd 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -15,6 +15,7 @@ ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}" ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_STASHED="(%{$fg_bold[blue]%}✹%{$reset_color%})" bureau_git_info () { local ref From 5901f30b44fc5a3055e6b801d3d71af6d2359ee8 Mon Sep 17 00:00:00 2001 From: WH-2099 Date: Thu, 25 May 2023 18:43:01 +0800 Subject: [PATCH 40/47] feat(archlinux): optimize `paclist` and `pacdisowned` (#11398) Co-authored-by: ratijas --- plugins/archlinux/README.md | 1 + plugins/archlinux/archlinux.plugin.zsh | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index fd772c61a..5e015dbaa 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -181,3 +181,4 @@ whether the package manager is installed, checked in the following order: - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Jeff M. Hubbard - jeffmhubbard@gmail.com - K. Harishankar(harishnkr) - hari2menon1234@gmail.com +- WH-2099 - wh2099@outlook.com \ No newline at end of file diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index da170f488..796ff7adf 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -25,27 +25,28 @@ alias pacown='pacman -Qo' alias pacupd="sudo pacman -Sy" function paclist() { - # Based on https://bbs.archlinux.org/viewtopic.php?id=93683 - pacman -Qqe | \ - xargs -I '{}' \ - expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}' + local pkgs=$(LC_ALL=C pacman -Qqe) + for pkg in ${(f)pkgs}; do + pacman -Qs --color=auto "^${pkg}\$" || break + done } function pacdisowned() { - local tmp db fs - tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ - db=$tmp/db - fs=$tmp/fs + local tmp_dir db fs + tmp_dir=$(mktemp --directory) + db=$tmp_dir/db + fs=$tmp_dir/fs - mkdir "$tmp" - trap 'rm -rf "$tmp"' EXIT + trap "rm -rf $tmp_dir" EXIT pacman -Qlq | sort -u > "$db" - find /bin /etc /lib /sbin /usr ! -name lost+found \ + find /etc /usr ! -name lost+found \ \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" comm -23 "$fs" "$db" + + rm -rf $tmp_dir } alias pacmanallkeys='sudo pacman-key --refresh-keys' From fb4213c34ff8ec83cbe6251f432fdac383378562 Mon Sep 17 00:00:00 2001 From: Tom D Date: Fri, 26 May 2023 09:43:17 +0200 Subject: [PATCH 41/47] perf(git): improve `gunwip` alias (#11714) --- plugins/git/README.md | 2 +- plugins/git/git.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index f87d3fbca..2742aa539 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -186,7 +186,7 @@ plugins=(... git) | gtv | git tag \| sort -V | | gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl | | gunignore | git update-index --no-assume-unchanged | -| gunwip | git log --max-count=1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gunwip | git rev-list --max-count=1 --format="%s" HEAD \| grep -q "\-\-wip\-\-" && git reset HEAD~1 | | gup | git pull --rebase | | gupv | git pull --rebase --verbose | | gupa | git pull --rebase --autostash | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 3c8d53c8c..4be865f6a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -312,7 +312,7 @@ alias gtv='git tag | sort -V' alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' -alias gunwip='git log --max-count=1 | grep -q -c "\--wip--" && git reset HEAD~1' +alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1' alias gup='git pull --rebase' alias gupv='git pull --rebase --verbose' alias gupa='git pull --rebase --autostash' From 00241073105643874531e1826b7df6d2cb3cadfb Mon Sep 17 00:00:00 2001 From: William Snyders Date: Wed, 31 May 2023 14:59:41 -0700 Subject: [PATCH 42/47] fix(gcloud): update AUR default location (#11718) --- 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 30f1dba8f..9c26aea10 100644 --- a/plugins/gcloud/gcloud.plugin.zsh +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -14,6 +14,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then "/usr/lib/google-cloud-sdk" "/usr/lib64/google-cloud-sdk" "/opt/google-cloud-sdk" + "/opt/google-cloud-cli" "/opt/local/libexec/google-cloud-sdk" ) From 6101106916147b1716ff2d5de4a53260e7607bae Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 2 Jun 2023 21:37:48 +0200 Subject: [PATCH 43/47] feat(install): deploy installer to install.ohmyz.sh (#11722) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- .github/workflows/installer.yml | 55 +++++++++++++++++++++++ .github/workflows/installer/.gitignore | 1 + .github/workflows/installer/.vercelignore | 2 + .github/workflows/installer/vercel.json | 14 ++++++ .github/workflows/main.yml | 2 - 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/installer.yml create mode 100644 .github/workflows/installer/.gitignore create mode 100644 .github/workflows/installer/.vercelignore create mode 100644 .github/workflows/installer/vercel.json diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml new file mode 100644 index 000000000..ac88d10b0 --- /dev/null +++ b/.github/workflows/installer.yml @@ -0,0 +1,55 @@ +name: Test and Deploy installer +on: + workflow_dispatch: {} + push: + paths: + - tools/install.sh + - .github/workflows/installer + - .github/workflows/installer.yml + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: false + +permissions: + contents: read # to checkout + +jobs: + test: + name: Test installer + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + steps: + - name: Set up git repository + uses: actions/checkout@v3 + - name: Install zsh + if: runner.os == 'Linux' + run: sudo apt-get update; sudo apt-get install zsh + - name: Test installer + run: sh ./tools/install.sh + + deploy: + name: Deploy installer in install.ohmyz.sh + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + environment: vercel + needs: + - test + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Vercel CLI + run: npm install -g vercel + - name: Setup project and deploy + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + run: | + cp tools/install.sh .github/workflows/installer/install.sh + cd .github/workflows/installer + vc link --yes -t ${{ secrets.VERCEL_TOKEN }} + vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/installer/.gitignore b/.github/workflows/installer/.gitignore new file mode 100644 index 000000000..f66fce310 --- /dev/null +++ b/.github/workflows/installer/.gitignore @@ -0,0 +1 @@ +install.sh diff --git a/.github/workflows/installer/.vercelignore b/.github/workflows/installer/.vercelignore new file mode 100644 index 000000000..41b233364 --- /dev/null +++ b/.github/workflows/installer/.vercelignore @@ -0,0 +1,2 @@ +/* +!/install.sh diff --git a/.github/workflows/installer/vercel.json b/.github/workflows/installer/vercel.json new file mode 100644 index 000000000..8c5aec5e0 --- /dev/null +++ b/.github/workflows/installer/vercel.json @@ -0,0 +1,14 @@ +{ + "headers": [ + { + "source": "/((?!favicon.ico).*)", + "headers": [{ "key": "Content-Type", "value": "text/plain" }] + } + ], + "rewrites": [ + { + "source": "/((?!favicon.ico|install.sh).*)", + "destination": "/install.sh" + } + ] +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ee2df3d8..57403629c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,8 +31,6 @@ jobs: - name: Install zsh if: runner.os == 'Linux' run: sudo apt-get update; sudo apt-get install zsh - - name: Test installer - run: sh ./tools/install.sh - name: Check syntax run: | for file in ./oh-my-zsh.sh \ From 62ab5406dd89848bb26e8c6e648eb7d860e9dce5 Mon Sep 17 00:00:00 2001 From: Lawrence Shah Date: Mon, 5 Jun 2023 01:20:32 -0700 Subject: [PATCH 44/47] docs(custom): update comments in example files (#11727) --- custom/example.zsh | 18 ++++++++++-------- custom/plugins/example/example.plugin.zsh | 1 + custom/themes/example.zsh-theme | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/custom/example.zsh b/custom/example.zsh index c505a9673..21a8d8be7 100644 --- a/custom/example.zsh +++ b/custom/example.zsh @@ -1,10 +1,12 @@ -# You can put files here to add functionality separated per file, which -# will be ignored by git. -# Files on the custom/ directory will be automatically loaded by the init -# script, in alphabetical order. - -# For example: add yourself some shortcuts to projects you often work on. -# +# Put files in this folder to add your own custom functionality. +# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization +# +# Files in the custom/ directory will be: +# - loaded automatically by the init script, in alphabetical order +# - loaded last, after all built-ins in the lib/ directory, to override them +# - ignored by git by default +# +# Example: add custom/shortcuts.zsh for shortcuts to your local projects +# # brainstormr=~/Projects/development/planetargon/brainstormr # cd $brainstormr -# diff --git a/custom/plugins/example/example.plugin.zsh b/custom/plugins/example/example.plugin.zsh index 406f27445..83611fe3f 100644 --- a/custom/plugins/example/example.plugin.zsh +++ b/custom/plugins/example/example.plugin.zsh @@ -1,2 +1,3 @@ # Add your own custom plugins in the custom/plugins directory. Plugins placed # here will override ones with the same name in the main plugins directory. +# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins diff --git a/custom/themes/example.zsh-theme b/custom/themes/example.zsh-theme index ef8f1c630..494d029e8 100644 --- a/custom/themes/example.zsh-theme +++ b/custom/themes/example.zsh-theme @@ -1,4 +1,6 @@ # Put your custom themes in this folder. +# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes +# # Example: PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " From b36c90d9abd2fd2ffe53d19b11e47077dfdb38a8 Mon Sep 17 00:00:00 2001 From: Diego Costa R <62116423+diegocostares@users.noreply.github.com> Date: Mon, 5 Jun 2023 04:25:17 -0400 Subject: [PATCH 45/47] feat(autoenv): macOS compatibility, add more dirs (#11724) Co-authored-by: Carlo Sala --- plugins/autoenv/autoenv.plugin.zsh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index 229a8a834..cbf7cefbb 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -17,9 +17,13 @@ if ! type autoenv_init >/dev/null; then /usr/local/bin /usr/share/autoenv-git ~/Library/Python/bin + .venv/bin + venv/bin + env/bin + .env/bin ) for d ( $install_locations ); do - if [[ -e $d/activate.sh ]]; then + if [[ -e $d/activate || -e $d/activate.sh ]]; then autoenv_dir=$d break fi @@ -29,13 +33,13 @@ if ! type autoenv_init >/dev/null; then # Look for Homebrew path as a last resort if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then d=$(brew --prefix)/opt/autoenv - if [[ -e $d/activate.sh ]]; then + if [[ -e $d/activate || -e $d/activate.sh ]]; then autoenv_dir=$d fi fi # Complain if autoenv is not installed - if [[ -z $autoenv_dir ]]; then + if [[ -z $autoenv_dir ]]; then cat <&2 -------- AUTOENV --------- Could not locate autoenv installation. @@ -46,7 +50,11 @@ END return 1 fi # Load autoenv - source $autoenv_dir/activate.sh + if [[ -e $autoenv_dir/activate ]]; + source $autoenv_dir/activate + else + source $autoenv_dir/activate.sh + fi fi } [[ $? != 0 ]] && return $? From d1c64bfda30ad56bac09f11c920b93b94dab7f9f Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 5 Jun 2023 10:26:36 +0200 Subject: [PATCH 46/47] fix(autoenv): typo --- plugins/autoenv/autoenv.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index cbf7cefbb..2f84f0acf 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -50,7 +50,7 @@ END return 1 fi # Load autoenv - if [[ -e $autoenv_dir/activate ]]; + if [[ -e $autoenv_dir/activate ]]; then source $autoenv_dir/activate else source $autoenv_dir/activate.sh From 115cee17015e4b5665e16dc4fd15c53e06a22f9a Mon Sep 17 00:00:00 2001 From: Ihor Date: Mon, 5 Jun 2023 10:38:54 +0200 Subject: [PATCH 47/47] feat(git): add `gunwipall` function (#11725) Co-authored-by: Carlo Sala --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 2742aa539..bf4b19f39 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -254,6 +254,7 @@ These features allow to pause a branch development and switch to another one (_" | work_in_progress | Echoes a warning if the current branch is a wip | | gwip | Commit wip branch | | gunwip | Uncommit wip branch | +| gunwipall | Uncommit `--wip--` commits recursively | ### Deprecated functions diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 4be865f6a..192124301 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -27,6 +27,20 @@ function work_in_progress() { command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" } +# Same as `gunwip` but recursive +# "Unwips" all recent `--wip--` commits in loop until there is no left +function gunwipall() { + while true; do + commit_message=$(git rev-list --max-count=1 --format="%s" HEAD) + if [[ $commit_message =~ "--wip--" ]]; then + git reset "HEAD~1" + (( $? )) && return 1 + else + break + fi + done +} + # Check if main exists and use instead of master function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return