From 7d2aedf199d1e27b6bea8ab33212043b055b3715 Mon Sep 17 00:00:00 2001 From: David LJ Date: Wed, 9 Aug 2023 18:27:39 +0200 Subject: [PATCH 01/36] chore(gitignore): use new API endpoint from TopTal (#11835) --- plugins/gitignore/README.md | 2 +- plugins/gitignore/gitignore.plugin.zsh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/gitignore/README.md b/plugins/gitignore/README.md index 753dd31fd..23c7887cf 100644 --- a/plugins/gitignore/README.md +++ b/plugins/gitignore/README.md @@ -1,6 +1,6 @@ # gitignore -This plugin enables you the use of [gitignore.io](https://www.gitignore.io/) from the command line. You need an active internet connection. +This plugin enables you the use of [gitignore.io](https://www.toptal.com/developers/gitignore) from the command line. You need an active internet connection. To use it, add `gitignore` to the plugins array in your zshrc file: diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index a687f5cce..3271d61a9 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,7 +1,7 @@ -function gi() { curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}" } +function gi() { curl -fLw '\n' https://www.toptal.com/developers/gitignore/api/"${(j:,:)@}" } _gitignoreio_get_command_list() { - curl -sfL https://www.gitignore.io/api/list | tr "," "\n" + curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n" } _gitignoreio () { From fd219a94ab585fa699a0e842335a9f33dcbb613b Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 10 Aug 2023 15:39:40 +0200 Subject: [PATCH 02/36] docs(aliases): replace screenshot Closes #11837 Closes #11822 --- plugins/aliases/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index 419554095..53b68ea01 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -25,4 +25,4 @@ Requirements: Python needs to be installed. - `als --groups`: show only group names - ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png) + ![screenshot](https://github.com/ohmyzsh/ohmyzsh/assets/66907184/5bfa00ea-5fc3-4e97-8b22-2f74f6b948c7) From b81915d3293cc4657cec64202b9fd991b96b4ba2 Mon Sep 17 00:00:00 2001 From: Jin Cheol <76617139+bik1111@users.noreply.github.com> Date: Wed, 16 Aug 2023 20:46:28 +0900 Subject: [PATCH 03/36] feat(terraform): add terraform version prompt (#11845) --- plugins/terraform/README.md | 13 ++++++++----- plugins/terraform/terraform.plugin.zsh | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index c19f2ad1c..fc9a9f005 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -1,7 +1,7 @@ # Terraform plugin -Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. -It adds completion for `terraform`, as well as aliases and a prompt function. +Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. It adds +completion for `terraform`, as well as aliases and a prompt function. To use it, add `terraform` to the plugins array of your `~/.zshrc` file: @@ -11,7 +11,7 @@ plugins=(... terraform) ## Requirements -* [Terraform](https://terraform.io/) +- [Terraform](https://terraform.io/) ## Aliases @@ -29,11 +29,12 @@ plugins=(... terraform) ## Prompt function -You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)` -to your `PROMPT` or `RPROMPT` variable. +You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`, +`$(tf_version_prompt_info)` to your `PROMPT` or `RPROMPT` variable. ```sh RPROMPT='$(tf_prompt_info)' +RPROMPT='$(tf_version_prompt_info)' ``` You can also specify the PREFIX and SUFFIX for the workspace with the following variables: @@ -41,4 +42,6 @@ You can also specify the PREFIX and SUFFIX for the workspace with the following ```sh ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}" ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_TF_VERSION_PROMPT_PREFIX="%{$fg[white]%}" +ZSH_THEME_TF_VERSION_PROMPT_SUFFIX="%{$reset_color%}" ``` diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index 7006f204b..ccca54684 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -8,6 +8,13 @@ function tf_prompt_info() { echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}" } +function tf_version_prompt_info() { + local terraform_version + terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2) + echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}" +} + + alias tf='terraform' alias tfa='terraform apply' alias tfc='terraform console' From 6bc4c80c7db072a0d2d265eb3589bbe52e0d2737 Mon Sep 17 00:00:00 2001 From: Ahmed Wael <73046395+ahmedwael216@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:07:28 +0300 Subject: [PATCH 04/36] fix(colored-man-pages): add env GROFF_NO_SGR=1 (#11831) --- plugins/colored-man-pages/colored-man-pages.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 981992d88..57facbb5c 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -36,6 +36,7 @@ function colored() { # Prefer `less` whenever available, since we specifically configured # environment for it. environment+=( PAGER="${commands[less]:-$PAGER}" ) + environment+=( GROFF_NO_SGR=1 ) # See ./nroff script. if [[ "$OSTYPE" = solaris* ]]; then From dfe2f04de7e839ae0a9757c37a26b9d8710aa372 Mon Sep 17 00:00:00 2001 From: LuckyWindsck Date: Tue, 22 Aug 2023 01:09:02 +0900 Subject: [PATCH 05/36] refactor(init): rename variable (#11851) --- oh-my-zsh.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index a577c1f41..40f13f37e 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -187,12 +187,12 @@ _omz_source() { fi } -# Load all of the config files in ~/oh-my-zsh that end in .zsh +# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh # TIP: Add files you don't want in git to .gitignore -for config_file ("$ZSH"/lib/*.zsh); do - _omz_source "lib/${config_file:t}" +for lib_file ("$ZSH"/lib/*.zsh); do + _omz_source "lib/${lib_file:t}" done -unset custom_config_file +unset lib_file # Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do From 3f477e5da5ee42356f103d2c5cdd478d23bf9f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 23 Aug 2023 13:25:33 +0200 Subject: [PATCH 06/36] fix(extract): extraction to directory for single-file .gz (#11852) --- plugins/extract/extract.plugin.zsh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index b7a823c9f..513950f33 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -64,7 +64,7 @@ EOF (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;; (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;; (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;; - (*.gz) (( $+commands[pigz] )) && pigz -dk "$full_path" || gunzip -k "$full_path" ;; + (*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;; (*.bz2) bunzip2 "$full_path" ;; (*.xz) unxz "$full_path" ;; (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;; @@ -106,19 +106,19 @@ EOF # - Y2: at most give 2 files local -a content content=("${extract_dir}"/*(DNY2)) - if [[ ${#content} -eq 1 && -d "${content[1]}" ]]; then - # The extracted folder (${content[1]}) may have the same name as $extract_dir + if [[ ${#content} -eq 1 && -e "${content[1]}" ]]; then + # The extracted file/folder (${content[1]}) may have the same name as $extract_dir # If so, we need to rename it to avoid conflicts in a 3-step process # - # 1. Move and rename the extracted folder to a temporary random name + # 1. Move and rename the extracted file/folder to a temporary random name # 2. Delete the empty folder - # 3. Rename the extracted folder to the original name + # 3. Rename the extracted file/folder to the original name 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 "${content[1]}" "$tmp_dir" \ + local tmp_name==(:); tmp_name="${tmp_name:t}" + command mv "${content[1]}" "$tmp_name" \ && command rmdir "$extract_dir" \ - && command mv "$tmp_dir" "$extract_dir" + && command mv "$tmp_name" "$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 From 33c0de7add12b050b94fd6f2f988e9b5547d172c Mon Sep 17 00:00:00 2001 From: Miguel Hargreaves Pimenta Date: Wed, 23 Aug 2023 12:38:32 +0100 Subject: [PATCH 07/36] refactor(git): sort git aliases alphabetically (#9743) --- plugins/git/README.md | 419 ++++++++++++------------ plugins/git/git.plugin.zsh | 634 ++++++++++++++++++------------------- 2 files changed, 527 insertions(+), 526 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index d18531955..0b757c481 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -10,213 +10,214 @@ plugins=(... git) ## Aliases -| Alias | Command | -| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| g | git | -| ga | git add | -| gaa | git add --all | -| gapa | git add --patch | -| gau | git add --update | -| gav | git add --verbose | -| gap | git apply | -| gapt | git apply --3way | -| gb | git branch | -| gba | git branch --all | -| 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 | git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d | -| gbgD | git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D | -| gbl | git blame -b -w | -| gbnm | git branch --no-merged | -| gbr | git branch --remote | -| gbs | git bisect | -| gbsb | git bisect bad | -| gbsg | git bisect good | -| gbsr | git bisect reset | -| gbss | git bisect start | -| gc | git commit --verbose | -| gc! | git commit --verbose --amend | -| gcn! | git commit --verbose --no-edit --amend | -| gca | git commit --verbose --all | -| gca! | git commit --verbose --all --amend | -| gcan! | git commit --verbose --all --no-edit --amend | -| gcans! | git commit --verbose --all --signoff --no-edit --amend | -| gcam | git commit --all --message | -| gcas | git commit --all --signoff | -| gcasm | git commit --all --signoff --message | -| gcsm | git commit --signoff --message | -| gcb | git checkout -b | -| gcf | git config --list | -| gcl | git clone --recurse-submodules | -| gccd | git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)" | -| gclean | git clean --interactive -d | -| gpristine | git reset --hard && git clean -dffx | -| gcm | git checkout $(git_main_branch) | -| gcd | git checkout $(git_develop_branch) | -| gcmsg | git commit --message | -| gco | git checkout | -| gcor | git checkout --recurse-submodules | -| gcount | git shortlog --summary -n | -| gcp | git cherry-pick | -| gcpa | git cherry-pick --abort | -| gcpc | git cherry-pick --continue | -| gcs | git commit -S | -| gcss | git commit -S -s | -| gcssm | git commit -S -s -m | -| gd | git diff | -| gdca | git diff --cached | -| gdcw | git diff --cached --word-diff | -| gdct | git describe --tags $(git rev-list --tags --max-count=1) | -| gds | git diff --staged | -| gdt | git diff-tree --no-commit-id --name-only -r | -| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" | -| gdup | git diff @{upstream} | -| gdv | git diff -w $@ \| view - | -| gdw | git diff --word-diff | -| gf | git fetch | -| gfa | git fetch --all --prune | -| gfg | git ls-files \| grep | -| gfo | git fetch origin | -| gg | git gui citool | -| gga | git gui citool --amend | -| ggf | git push --force origin $(current_branch) | -| ggfl | git push --force-with-lease origin $(current_branch) | -| ggl | git pull origin $(current_branch) | -| ggp | git push origin $(current_branch) | -| ggpnp | ggl && ggp | -| ggpull | git pull origin "$(git_current_branch)" | -| ggpur | ggu | -| ggpush | git push origin "$(git_current_branch)" | -| 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 --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:]]" | -| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | -| gk | gitk --all --branches &! | -| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! | -| gl | git pull | -| glg | git log --stat | -| glgp | git log --stat --patch | -| glgg | git log --graph | -| glgga | git log --graph --decorate --all | -| glgm | git log --graph --max-count=10 | -| glo | git log --oneline --decorate | -| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' | -| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat | -| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | -| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | -| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all | -| glog | git log --oneline --decorate --graph | -| 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 | -| gmum | git merge upstream/$(git_main_branch) | -| gma | git merge --abort | -| gp | git push | -| gpd | git push --dry-run | -| 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 | -| gpod | git push origin --delete | -| gpr | git pull --rebase | -| gpu | git push upstream | -| gpv | git push --verbose | -| gr | git remote | -| gra | git remote add | -| grb | git rebase | -| grba | git rebase --abort | -| grbc | git rebase --continue | -| grbd | git rebase $(git_develop_branch) | -| grbi | git rebase --interactive | -| grbm | git rebase $(git_main_branch) | -| grbom | git rebase origin/$(git_main_branch) | -| grbo | git rebase --onto | -| grbs | git rebase --skip | -| grev | git revert | -| grh | git reset | -| grhh | git reset --hard | -| groh | git reset origin/$(git_current_branch) --hard | -| grm | git rm | -| grmc | git rm --cached | -| grmv | git remote rename | -| grrm | git remote remove | -| grs | git restore | -| grset | git remote set-url | -| grss | git restore --source | -| grst | git restore --staged | -| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | -| gru | git reset -- | -| grup | git remote update | -| grv | git remote --verbose | -| gsb | git status --short -b | -| gsd | git svn dcommit | -| gsh | git show | -| gsi | git submodule init | -| gsps | git show --pretty=short --show-signature | -| gsr | git svn rebase | -| gss | git status --short | -| gst | git status | -| gsta | git stash push (git version >= 2.13) | -| gsta | git stash save (git version < 2.13) | -| gstaa | git stash apply | -| gstc | git stash clear | -| gstd | git stash drop | -| gstl | git stash list | -| gstp | git stash pop | -| gsts | git stash show --text | -| gstu | git stash --include-untracked | -| gstall | git stash --all | -| gsu | git submodule update | -| gsw | git switch | -| gswc | git switch -c | -| gswm | git switch $(git_main_branch) | -| gswd | git switch $(git_develop_branch) | -| gts | git tag -s | -| 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 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 | -| gupav | git pull --rebase --autostash --verbose | -| gupom | git pull --rebase origin $(git_main_branch) | -| gupomi | git pull --rebase=interactive origin $(git_main_branch) | -| glum | git pull upstream $(git_main_branch) | -| gluc | git pull upstream $(git_current_branch) | -| gwch | git whatchanged -p --abbrev-commit --pretty=medium | -| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]" | -| gam | git am | -| gamc | git am --continue | -| gams | git am --skip | -| gama | git am --abort | -| gamscp | git am --show-current-patch | -| gwt | git worktree | -| gwtls | git worktree list | -| gwtmv | git worktree move | -| gwtrm | git worktree remove | +| Alias | Command | +| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| grt | cd "$(git rev-parse --show-toplevel || echo .)" | +| ggpnp | ggl && ggp | +| ggpur | ggu | +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]" | +| gam | git am | +| gama | git am --abort | +| gamc | git am --continue | +| gamscp | git am --show-current-patch | +| gams | git am --skip | +| gap | git apply | +| gapt | git apply --3way | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gbl | git blame -b -w | +| gb | git branch | +| gba | git branch --all | +| gbd | git branch --delete | +| gbD | git branch --delete --force | +| gbda | git branch --no-color --merged | grep -vE "^([+]|\s($(git_main_branch)|$(git_develop_branch))\s\*$)" | xargs git branch --delete 2>/dev/null | +| gbgd | git branch --no-color -vv | +| gbgD | git branch --no-color -vv | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| gbg | git branch -vv | +| gco | git checkout | +| gcor | git checkout --recurse-submodules | +| gcb | git checkout -b | +| gcd | git checkout $(git_develop_branch) | +| gcm | git checkout $(git_main_branch) | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gclean | git clean --interactive -d | +| gcl | git clone --recurse-submodules | +| gccd | git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)" | +| gcam | git commit --all --message | +| gcas | git commit --all --signoff | +| gcasm | git commit --all --signoff --message | +| gcmsg | git commit --message | +| gcsm | git commit --signoff --message | +| gc | git commit --verbose | +| gca | git commit --verbose --all | +| gca! | git commit --verbose --all --amend | +| gcan! | git commit --verbose --all --no-edit --amend | +| gcans! | git commit --verbose --all --signoff --no-edit --amend | +| gc! | git commit --verbose --amend | +| gcn! | git commit --verbose --no-edit --amend | +| gcs | git commit -S | +| gcss | git commit -S -s | +| gcssm | git commit -S -s -m | +| gcf | git config --list | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gds | git diff --staged | +| gdw | git diff --word-diff | +| gdv | git diff -w $@ | view - | +| gdup | git diff @{upstream} | +| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ghh | git help | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat | +| glo | git log --oneline --decorate | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | git log --pretty=\ | +| glg | git log --stat | +| glgp | git log --stat --patch | +| gignored | git ls-files -v | grep "^[[:lower:]]" | +| gfg | git ls-files | grep | +| gm | git merge | +| gma | git merge --abort | +| gms | git merge --squash | +| gmom | git merge origin/$(git_main_branch) | +| gmum | git merge upstream/$(git_main_branch) | +| gmtl | git mergetool --no-prompt | +| gmtlvim | git mergetool --no-prompt --tool=vimdiff | +| gl | git pull | +| gpr | git pull --rebase | +| gup | git pull --rebase | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash --verbose | +| gupv | git pull --rebase --verbose | +| ggu | git pull --rebase origin $(current_branch) | +| gupom | git pull --rebase origin $(git_main_branch) | +| gupomi | git pull --rebase=interactive origin $(git_main_branch) | +| ggpull | git pull origin "$(git_current_branch)" | +| ggl | git pull origin $(current_branch) | +| gluc | git pull upstream $(git_current_branch) | +| glum | git pull upstream $(git_main_branch) | +| gp | git push | +| gpd | git push --dry-run | +| gpf! | git push --force | +| ggf | git push --force origin $(current_branch) | +| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) | +| gpf | git push --force-with-lease (git version < 2.30) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| 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) | +| gpv | git push --verbose | +| gpoat | git push origin --all && git push origin --tags | +| gpod | git push origin --delete | +| ggpush | git push origin "$(git_current_branch)" | +| ggp | git push origin $(current_branch) | +| gpu | git push upstream | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbi | git rebase --interactive | +| grbo | git rebase --onto | +| grbs | git rebase --skip | +| grbd | git rebase $(git_develop_branch) | +| grbm | git rebase $(git_main_branch) | +| grbom | git rebase origin/$(git_main_branch) | +| gr | git remote | +| grv | git remote --verbose | +| gra | git remote add | +| grrm | git remote remove | +| grmv | git remote rename | +| grset | git remote set-url | +| grup | git remote update | +| grh | git reset | +| gru | git reset -- | +| grhh | git reset --hard | +| gpristine | git reset --hard && git clean -dffx | +| groh | git reset origin/$(git_current_branch) --hard | +| grs | git restore | +| grss | git restore --source | +| grst | git restore --staged | +| gunwip | git rev-list --max-count=1 --format="%s" HEAD | grep -q "--wip--" && git reset HEAD~1 | +| grev | git revert | +| grm | git rm | +| grmc | git rm --cached | +| gcount | git shortlog --summary -n | +| gsh | git show | +| gsps | git show --pretty=short --show-signature | +| gstall | git stash --all | +| gstu | git stash --include-untracked | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsta | git stash push (git version >= 2.13) | +| gsta | git stash save (git version < 2.13) | +| gsts | git stash show --text | +| gst | git status | +| gss | git status --short | +| gsb | git status --short -b | +| gsi | git submodule init | +| gsu | git submodule update | +| gsd | git svn dcommit | +| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | +| gsr | git svn rebase | +| gsw | git switch | +| gswc | git switch -c | +| gswd | git switch $(git_develop_branch) | +| gswm | git switch $(git_main_branch) | +| gts | git tag -s | +| gtv | git tag | sort -V | +| gignore | git update-index --assume-unchanged | +| gunignore | git update-index --no-assume-unchanged | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwt | git worktree | +| gwtls | git worktree list | +| gwtmv | git worktree move | +| gwtrm | git worktree remove | +| gk | gitk --all --branches &! | +| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! | +| gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl | ### Main branch preference -Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using -a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means -that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the -function `git_main_branch`. +Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin +favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive +term `main`. This means that any aliases and functions that previously used `master`, will use `main` if that +branch exists. We do this via the function `git_main_branch`. ### Deprecated aliases -These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. +These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, +receive further support. | Alias | Command | Modification | | :----- | :----------------------------------------------------- | :----------------------------------------------------- | @@ -238,23 +239,27 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa | Command | Description | | :--------------------- | :------------------------------------------------------------------------------------------------------- | -| `grename ` | Rename `old` branch to `new`, including in origin remote | | current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | -| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| git_current_user_email | Returns the `user.email` config value (lives in lib/git.zsh) | +| git_current_user_name | Returns the `user.name` config value (lives in lib/git.zsh) | | git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise | +| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| grename \ \ | Rename `old` branch to `new`, including in origin remote | ### Work in Progress (WIP) -These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it. +These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). +When you want to go back to work, just unwip it. | Command | Description | | :--------------- | :---------------------------------------------- | -| work_in_progress | Echoes a warning if the current branch is a wip | | gwip | Commit wip branch | | gunwip | Uncommit wip branch | | gunwipall | Uncommit all recent `--wip--` commits | +| work_in_progress | Echoes a warning if the current branch is a wip | + +Note that `gwip` and `gunwip` are effectivly alias, but are also documented here to group all related WIP +features. ### Deprecated functions diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d04edea5e..b321ce7b0 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -3,7 +3,9 @@ autoload -Uz is-at-least git_version="${${(As: :)$(git version 2>/dev/null)}[3]}" # -# Functions +# Functions Current +# (sorted alphabetically by function name) +# (order should follow README) # # The name of the current branch @@ -14,42 +16,6 @@ function current_branch() { git_current_branch } -# Pretty log messages -function _git_log_prettily(){ - if ! [ -z $1 ]; then - git log --pretty=$1 - fi -} -compdef _git _git_log_prettily=git-log - -# Warn if the current branch is a WIP -function work_in_progress() { - command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" -} - -# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one -function gunwipall() { - local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H) - - # Check if a commit without "--wip--" was found and it's not the same as HEAD - if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then - git reset $_commit || return 1 - fi -} - -# Check if main exists and use instead of master -function git_main_branch() { - command git rev-parse --git-dir &>/dev/null || return - local ref - for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do - if command git show-ref -q --verify $ref; then - echo ${ref:t} - return - fi - done - echo master -} - # Check for develop and similarly named branches function git_develop_branch() { command git rev-parse --git-dir &>/dev/null || return @@ -63,289 +29,18 @@ function git_develop_branch() { echo develop } -# -# Aliases -# (sorted alphabetically) -# - -alias g='git' - -alias ga='git add' -alias gaa='git add --all' -alias gapa='git add --patch' -alias gau='git add --update' -alias gav='git add --verbose' -alias gap='git apply' -alias gapt='git apply --3way' - -alias gb='git branch' -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='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' -alias gbgD='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' -alias gbl='git blame -b -w' -alias gbnm='git branch --no-merged' -alias gbr='git branch --remote' -alias gbs='git bisect' -alias gbsb='git bisect bad' -alias gbsg='git bisect good' -alias gbsr='git bisect reset' -alias gbss='git bisect start' - -alias gc='git commit --verbose' -alias gc!='git commit --verbose --amend' -alias gcn!='git commit --verbose --no-edit --amend' -alias gca='git commit --verbose --all' -alias gca!='git commit --verbose --all --amend' -alias gcan!='git commit --verbose --all --no-edit --amend' -alias gcans!='git commit --verbose --all --signoff --no-edit --amend' -alias gcam='git commit --all --message' -alias gcsm='git commit --signoff --message' -alias gcas='git commit --all --signoff' -alias gcasm='git commit --all --signoff --message' -alias gcb='git checkout -b' -alias gcf='git config --list' - -function gccd() { - command git clone --recurse-submodules "$@" - [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}" +# Check if main exists and use instead of master +function git_main_branch() { + command git rev-parse --git-dir &>/dev/null || return + local ref + for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do + if command git show-ref -q --verify $ref; then + echo ${ref:t} + return + fi + done + echo master } -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 -dfx' -alias gcm='git checkout $(git_main_branch)' -alias gcd='git checkout $(git_develop_branch)' -alias gcmsg='git commit --message' -alias gco='git checkout' -alias gcor='git checkout --recurse-submodules' -alias gcount='git shortlog --summary --numbered' -alias gcp='git cherry-pick' -alias gcpa='git cherry-pick --abort' -alias gcpc='git cherry-pick --continue' -alias gcs='git commit --gpg-sign' -alias gcss='git commit --gpg-sign --signoff' -alias gcssm='git commit --gpg-sign --signoff --message' - -alias gd='git diff' -alias gdca='git diff --cached' -alias gdcw='git diff --cached --word-diff' -alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' -alias gds='git diff --staged' -alias gdt='git diff-tree --no-commit-id --name-only -r' -alias gdup='git diff @{upstream}' -alias gdw='git diff --word-diff' - -function gdnolock() { - git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" -} -compdef _git gdnolock=git-diff - -function gdv() { git diff -w "$@" | view - } -compdef _git gdv=git-diff - -alias gf='git fetch' -# --jobs= was added in git 2.8 -is-at-least 2.8 "$git_version" \ - && alias gfa='git fetch --all --prune --jobs=10' \ - || alias gfa='git fetch --all --prune' -alias gfo='git fetch origin' - -alias gfg='git ls-files | grep' - -alias gg='git gui citool' -alias gga='git gui citool --amend' - -function ggf() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force origin "${b:=$1}" -} -compdef _git ggf=git-checkout -function ggfl() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force-with-lease origin "${b:=$1}" -} -compdef _git ggfl=git-checkout - -function ggl() { - if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then - git pull origin "${*}" - else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git pull origin "${b:=$1}" - fi -} -compdef _git ggl=git-checkout - -function ggp() { - if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then - git push origin "${*}" - else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git push origin "${b:=$1}" - fi -} -compdef _git ggp=git-checkout - -function ggpnp() { - if [[ "$#" == 0 ]]; then - ggl && ggp - else - ggl "${*}" && ggp "${*}" - fi -} -compdef _git ggpnp=git-checkout - -function ggu() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git pull --rebase origin "${b:=$1}" -} -compdef _git ggu=git-checkout - -alias ggpur='ggu' -alias ggpull='git pull origin "$(git_current_branch)"' -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)' -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' - -alias gignore='git update-index --assume-unchanged' -alias gignored='git ls-files -v | grep "^[[:lower:]]"' -alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' - -alias gk='\gitk --all --branches &!' -alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' - -alias gl='git pull' -alias glg='git log --stat' -alias glgp='git log --stat --patch' -alias glgg='git log --graph' -alias glgga='git log --graph --decorate --all' -alias glgm='git log --graph --max-count=10' -alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'" -alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat" -alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" -alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" -alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all" -alias glog='git log --oneline --decorate --graph' -alias gloga='git log --oneline --decorate --graph --all' -alias glp="_git_log_prettily" - -alias gm='git merge' -alias gmom='git merge origin/$(git_main_branch)' -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' -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 gpod='git push origin --delete' -alias gpr='git pull --rebase' -alias gpu='git push upstream' -alias gpv='git push --verbose' - -alias gr='git remote' -alias gra='git remote add' -alias grb='git rebase' -alias grba='git rebase --abort' -alias grbc='git rebase --continue' -alias grbd='git rebase $(git_develop_branch)' -alias grbi='git rebase --interactive' -alias grbm='git rebase $(git_main_branch)' -alias grbom='git rebase origin/$(git_main_branch)' -alias grbo='git rebase --onto' -alias grbs='git rebase --skip' -alias grev='git revert' -alias grh='git reset' -alias grhh='git reset --hard' -alias groh='git reset origin/$(git_current_branch) --hard' -alias grm='git rm' -alias grmc='git rm --cached' -alias grmv='git remote rename' -alias grrm='git remote remove' -alias grs='git restore' -alias grset='git remote set-url' -alias grss='git restore --source' -alias grst='git restore --staged' -alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' -alias gru='git reset --' -alias grup='git remote update' -alias grv='git remote --verbose' - -alias gsb='git status --short --branch' -alias gsd='git svn dcommit' -alias gsh='git show' -alias gsi='git submodule init' -alias gsps='git show --pretty=short --show-signature' -alias gsr='git svn rebase' -alias gss='git status --short' -alias gst='git status' - -# use the default stash push on git 2.13 and newer -is-at-least 2.13 "$git_version" \ - && alias gsta='git stash push' \ - || alias gsta='git stash save' - -alias gstaa='git stash apply' -alias gstc='git stash clear' -alias gstd='git stash drop' -alias gstl='git stash list' -alias gstp='git stash pop' -alias gsts='git stash show --text' -alias gstu='gsta --include-untracked' -alias gstall='git stash --all' -alias gsu='git submodule update' -alias gsw='git switch' -alias gswc='git switch --create' -alias gswm='git switch $(git_main_branch)' -alias gswd='git switch $(git_develop_branch)' - -alias gts='git tag --sign' -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 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' -alias gupav='git pull --rebase --autostash --verbose' -alias gupom='git pull --rebase origin $(git_main_branch)' -alias gupomi='git pull --rebase=interactive origin $(git_main_branch)' -alias glum='git pull upstream $(git_main_branch)' -alias gluc='git pull upstream $(git_current_branch)' - -alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' - -alias gwt='git worktree' -alias gwta='git worktree add' -alias gwtls='git worktree list' -alias gwtmv='git worktree move' -alias gwtrm='git worktree remove' - -alias gam='git am' -alias gamc='git am --continue' -alias gams='git am --skip' -alias gama='git am --abort' -alias gamscp='git am --show-current-patch' function grename() { if [[ -z "$1" || -z "$2" ]]; then @@ -361,4 +56,305 @@ function grename() { fi } +# +# Functions Work in Progress (WIP) +# (sorted alphabetically by function name) +# (order should follow README) +# + +# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one +function gunwipall() { + local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H) + + # Check if a commit without "--wip--" was found and it's not the same as HEAD + if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then + git reset $_commit || return 1 + fi +} + +# Warn if the current branch is a WIP +function work_in_progress() { + command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" +} + +# +# Aliases +# (sorted alphabetically by command) +# (order should follow README) +# (in some cases force the alisas order to match README, like for example gke and gk) +# + +alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' + +function ggpnp() { + if [[ "$#" == 0 ]]; then + ggl && ggp + else + ggl "${*}" && ggp "${*}" + fi +} +compdef _git ggpnp=git-checkout + +alias ggpur='ggu' +alias g='git' +alias ga='git add' +alias gaa='git add --all' +alias gapa='git add --patch' +alias gau='git add --update' +alias gav='git add --verbose' +alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' +alias gam='git am' +alias gama='git am --abort' +alias gamc='git am --continue' +alias gamscp='git am --show-current-patch' +alias gams='git am --skip' +alias gap='git apply' +alias gapt='git apply --3way' +alias gbs='git bisect' +alias gbsb='git bisect bad' +alias gbsg='git bisect good' +alias gbsr='git bisect reset' +alias gbss='git bisect start' +alias gbl='git blame -b -w' +alias gb='git branch' +alias gba='git branch --all' +alias gbd='git branch --delete' +alias gbD='git branch --delete --force' +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 gbgd='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' +alias gbgD='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' +alias gbnm='git branch --no-merged' +alias gbr='git branch --remote' +alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' +alias gbg='git branch -vv | grep ": gone\]"' +alias gco='git checkout' +alias gcor='git checkout --recurse-submodules' +alias gcb='git checkout -b' +alias gcd='git checkout $(git_develop_branch)' +alias gcm='git checkout $(git_main_branch)' +alias gcp='git cherry-pick' +alias gcpa='git cherry-pick --abort' +alias gcpc='git cherry-pick --continue' +alias gclean='git clean --interactive -d' +alias gcl='git clone --recurse-submodules' + +function gccd() { + command git clone --recurse-submodules "$@" + [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}" +} +compdef _git gccd=git-clone + +alias gcam='git commit --all --message' +alias gcas='git commit --all --signoff' +alias gcasm='git commit --all --signoff --message' +alias gcs='git commit --gpg-sign' +alias gcss='git commit --gpg-sign --signoff' +alias gcssm='git commit --gpg-sign --signoff --message' +alias gcmsg='git commit --message' +alias gcsm='git commit --signoff --message' +alias gc='git commit --verbose' +alias gca='git commit --verbose --all' +alias gca!='git commit --verbose --all --amend' +alias gcan!='git commit --verbose --all --no-edit --amend' +alias gcans!='git commit --verbose --all --signoff --no-edit --amend' +alias gc!='git commit --verbose --amend' +alias gcn!='git commit --verbose --no-edit --amend' +alias gcf='git config --list' +alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' +alias gd='git diff' +alias gdca='git diff --cached' +alias gdcw='git diff --cached --word-diff' +alias gds='git diff --staged' +alias gdw='git diff --word-diff' + +function gdv() { git diff -w "$@" | view - } +compdef _git gdv=git-diff + +alias gdup='git diff @{upstream}' + +function gdnolock() { + git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" +} +compdef _git gdnolock=git-diff + +alias gdt='git diff-tree --no-commit-id --name-only -r' +alias gf='git fetch' +# --jobs= was added in git 2.8 +is-at-least 2.8 "$git_version" \ + && alias gfa='git fetch --all --prune --jobs=10' \ + || alias gfa='git fetch --all --prune' +alias gfo='git fetch origin' +alias gg='git gui citool' +alias gga='git gui citool --amend' +alias ghh='git help' +alias glgg='git log --graph' +alias glgga='git log --graph --decorate --all' +alias glgm='git log --graph --max-count=10' +alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short' +alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"' +alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all' +alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat' +alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"' +alias glo='git log --oneline --decorate' +alias glog='git log --oneline --decorate --graph' +alias gloga='git log --oneline --decorate --graph --all' + +# Pretty log messages +function _git_log_prettily(){ + if ! [ -z $1 ]; then + git log --pretty=$1 + fi +} +compdef _git _git_log_prettily=git-log + +alias glp='_git_log_prettily' +alias glg='git log --stat' +alias glgp='git log --stat --patch' +alias gignored='git ls-files -v | grep "^[[:lower:]]"' +alias gfg='git ls-files | grep' +alias gm='git merge' +alias gma='git merge --abort' +alias gms="git merge --squash" +alias gmom='git merge origin/$(git_main_branch)' +alias gmum='git merge upstream/$(git_main_branch)' +alias gmtl='git mergetool --no-prompt' +alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' +alias gl='git pull' +alias gpr='git pull --rebase' +alias gup='git pull --rebase' +alias gupa='git pull --rebase --autostash' +alias gupav='git pull --rebase --autostash --verbose' +alias gupv='git pull --rebase --verbose' + +function ggu() { + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git pull --rebase origin "${b:=$1}" +} +compdef _git ggu=git-checkout + +alias gupom='git pull --rebase origin $(git_main_branch)' +alias gupomi='git pull --rebase=interactive origin $(git_main_branch)' +alias ggpull='git pull origin "$(git_current_branch)"' + +function ggl() { + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git pull origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git pull origin "${b:=$1}" + fi +} +compdef _git ggl=git-checkout + +alias gluc='git pull upstream $(git_current_branch)' +alias glum='git pull upstream $(git_main_branch)' +alias gp='git push' +alias gpd='git push --dry-run' + +function ggf() { + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git push --force origin "${b:=$1}" +} +compdef _git ggf=git-checkout + +alias gpf!='git push --force' +is-at-least 2.30 "$git_version" \ + && alias gpf='git push --force-with-lease --force-if-includes' \ + || alias gpf='git push --force-with-lease' + +function ggfl() { + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git push --force-with-lease origin "${b:=$1}" +} +compdef _git ggfl=git-checkout + +alias gpsup='git push --set-upstream origin $(git_current_branch)' +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 gpv='git push --verbose' +alias gpoat='git push origin --all && git push origin --tags' +alias gpod='git push origin --delete' +alias ggpush='git push origin "$(git_current_branch)"' + +function ggp() { + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git push origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git push origin "${b:=$1}" + fi +} +compdef _git ggp=git-checkout + +alias gpu='git push upstream' +alias grb='git rebase' +alias grba='git rebase --abort' +alias grbc='git rebase --continue' +alias grbi='git rebase --interactive' +alias grbo='git rebase --onto' +alias grbs='git rebase --skip' +alias grbd='git rebase $(git_develop_branch)' +alias grbm='git rebase $(git_main_branch)' +alias grbom='git rebase origin/$(git_main_branch)' +alias gr='git remote' +alias grv='git remote --verbose' +alias gra='git remote add' +alias grrm='git remote remove' +alias grmv='git remote rename' +alias grset='git remote set-url' +alias grup='git remote update' +alias grh='git reset' +alias gru='git reset --' +alias grhh='git reset --hard' +alias gpristine='git reset --hard && git clean --force -dfx' +alias groh='git reset origin/$(git_current_branch) --hard' +alias grs='git restore' +alias grss='git restore --source' +alias grst='git restore --staged' +alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1' +alias grev='git revert' +alias grm='git rm' +alias grmc='git rm --cached' +alias gcount='git shortlog --summary --numbered' +alias gsh='git show' +alias gsps='git show --pretty=short --show-signature' +alias gstall='git stash --all' +alias gstaa='git stash apply' +alias gstc='git stash clear' +alias gstd='git stash drop' +alias gstl='git stash list' +alias gstp='git stash pop' +# use the default stash push on git 2.13 and newer +is-at-least 2.13 "$git_version" \ + && alias gsta='git stash push' \ + || alias gsta='git stash save' +alias gsts='git stash show --text' +alias gst='git status' +alias gss='git status --short' +alias gsb='git status --short --branch' +alias gsi='git submodule init' +alias gsu='git submodule update' +alias gsd='git svn dcommit' +alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' +alias gsr='git svn rebase' +alias gsw='git switch' +alias gswc='git switch --create' +alias gswd='git switch $(git_develop_branch)' +alias gswm='git switch $(git_main_branch)' +alias gts='git tag --sign' +alias gtv='git tag | sort -V' +alias gignore='git update-index --assume-unchanged' +alias gunignore='git update-index --no-assume-unchanged' +alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' +alias gwt='git worktree' +alias gwta='git worktree add' +alias gwtls='git worktree list' +alias gwtmv='git worktree move' +alias gwtrm='git worktree remove' +alias gstu='gsta --include-untracked' +alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' +alias gk='\gitk --all --branches &!' +alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' + unset git_version From c92af18c36c84cef0c785e1ae9cabc49a61a5c3a Mon Sep 17 00:00:00 2001 From: Zhang Visper Date: Thu, 24 Aug 2023 17:37:38 +0800 Subject: [PATCH 08/36] fix(git): some aliases under non-english LANG (#11855) --- plugins/git/README.md | 6 +++--- plugins/git/git.plugin.zsh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 0b757c481..c3e6dd27d 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -40,12 +40,12 @@ plugins=(... git) | gbd | git branch --delete | | gbD | git branch --delete --force | | gbda | git branch --no-color --merged | grep -vE "^([+]|\s($(git_main_branch)|$(git_develop_branch))\s\*$)" | xargs git branch --delete 2>/dev/null | -| gbgd | git branch --no-color -vv | -| gbgD | git branch --no-color -vv | +| gbgd | LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d | +| gbgD | LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D | | gbnm | git branch --no-merged | | gbr | git branch --remote | | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | -| gbg | git branch -vv | +| gbg | LANG=C git branch -vv | grep ": gone\]" | | gco | git checkout | | gcor | git checkout --recurse-submodules | | gcb | git checkout -b | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index b321ce7b0..8886aac6d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -121,12 +121,12 @@ alias gba='git branch --all' alias gbd='git branch --delete' alias gbD='git branch --delete --force' 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 gbgd='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' -alias gbgD='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' +alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' +alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' -alias gbg='git branch -vv | grep ": gone\]"' +alias gbg='LANG=C git branch -vv | grep ": gone\]"' alias gco='git checkout' alias gcor='git checkout --recurse-submodules' alias gcb='git checkout -b' From 13a8e3d98aeeb4f5f0b98f92ace540067e58ba92 Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Fri, 25 Aug 2023 00:12:59 +0900 Subject: [PATCH 09/36] feat(alias-finder): add cheaper option and apply zstyle options (#11773) --- plugins/alias-finder/.zunit.yml | 9 ++ plugins/alias-finder/README.md | 55 ++++----- plugins/alias-finder/alias-finder.plugin.zsh | 79 +++++++------ plugins/alias-finder/tests/_output/.gitkeep | 0 plugins/alias-finder/tests/_support/.gitkeep | 0 plugins/alias-finder/tests/_support/bootstrap | 2 + plugins/alias-finder/tests/test_run.sh | 107 ++++++++++++++++++ 7 files changed, 186 insertions(+), 66 deletions(-) create mode 100644 plugins/alias-finder/.zunit.yml create mode 100644 plugins/alias-finder/tests/_output/.gitkeep create mode 100644 plugins/alias-finder/tests/_support/.gitkeep create mode 100644 plugins/alias-finder/tests/_support/bootstrap create mode 100644 plugins/alias-finder/tests/test_run.sh diff --git a/plugins/alias-finder/.zunit.yml b/plugins/alias-finder/.zunit.yml new file mode 100644 index 000000000..ae65f8ef2 --- /dev/null +++ b/plugins/alias-finder/.zunit.yml @@ -0,0 +1,9 @@ +tap: false +directories: + tests: tests + output: tests/_output + support: tests/_support +time_limit: 0 +fail_fast: false +allow_risky: false +verbose: true diff --git a/plugins/alias-finder/README.md b/plugins/alias-finder/README.md index 409f4b653..6c87c723a 100644 --- a/plugins/alias-finder/README.md +++ b/plugins/alias-finder/README.md @@ -2,45 +2,32 @@ This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier. +## Usage + To use it, add `alias-finder` to the `plugins` array of your zshrc file: ``` plugins=(... alias-finder) ``` -## Usage -To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this. +To enable it for every single command, set zstyle in your `~/.zshrc`. -## Options +```zsh +# ~/.zshrc + +zstyle ':omz:plugins:alias-finder' autoload yes # disabled by default +zstyle ':omz:plugins:alias-finder' longer yes # disabled by default +zstyle ':omz:plugins:alias-finder' exact yes # disabled by default +zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default +``` + +As you can see, options are also available with zstyle. + +### Options + +> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'. + +- Use `--longer` or `-l` to include aliases where the source is longer than the input (in other words, the source could contain the whole input). +- Use `--exact` or `-e` to avoid aliases where the source is shorter than the input (in other words, the source must be the same with the input). +- Use `--cheaper` or `-c` to avoid aliases where the destination is longer than the input (in other words, the destination must be the shorter than the input). -- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input). -- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input. -## Examples -``` -$ alias-finder "git pull" -gl='git pull' -g=git -``` -``` -$ alias-finder "web_search google oh my zsh" -google='web_search google' -``` -``` -$ alias-finder "git commit -v" -gc="git commit -v" -g=git -``` -``` -$ alias-finder -e "git commit -v" -gc='git commit -v' -``` -``` -$ alias-finder -l "git commit -v" -gc='git commit -v' -'gc!'='git commit -v --amend' -gca='git commit -v -a' -'gca!'='git commit -v -a --amend' -'gcan!'='git commit -v -a --no-edit --amend' -'gcans!'='git commit -v -a -s --no-edit --amend' -'gcn!'='git commit -v --no-edit --amend' -``` diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh index caee9b5a3..5fdfbc835 100644 --- a/plugins/alias-finder/alias-finder.plugin.zsh +++ b/plugins/alias-finder/alias-finder.plugin.zsh @@ -1,44 +1,59 @@ alias-finder() { - local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd="" - for i in $@; do - case $i in + local cmd=" " exact="" longer="" cheaper="" wordEnd="'{0,1}$" finder="" filter="" + + # build command and options + for c in "$@"; do + case $c in + # TODO: Remove backward compatibility (other than zstyle form) + # set options if exist -e|--exact) exact=true;; -l|--longer) longer=true;; - *) - if [[ -z $cmd ]]; then - cmd=$i - else - cmd="$cmd $i" - fi - ;; + -c|--cheaper) cheaper=true;; + # concatenate cmd + *) cmd="$cmd$c " ;; esac done - cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep - if (( $(wc -l <<< $cmd) == 1 )); then - while [[ $cmd != "" ]]; do - if [[ $longer = true ]]; then - wordStart="'{0,1}" - else - wordEnd="$" - multiWordEnd="'$" - fi - if [[ $cmd == *" "* ]]; then - local finder="'$cmd$multiWordEnd" - else - local finder=$wordStart$cmd$wordEnd - fi - alias | grep -E "=$finder" - if [[ $exact = true || $longer = true ]]; then - break - else - cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word - fi - done + + zstyle -t ':omz:plugins:alias-finder' longer && longer=true + zstyle -t ':omz:plugins:alias-finder' exact && exact=true + zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true + + # format cmd for grep + ## - replace newlines with spaces + ## - trim both ends + ## - replace multiple spaces with one space + ## - add escaping character to special characters + cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g') + + if [[ $longer == true ]]; then + wordEnd="" # remove wordEnd to find longer aliases fi + + # find with alias and grep, removing last word each time until no more words + while [[ $cmd != "" ]]; do + finder="'{0,1}$cmd$wordEnd" + + # make filter to find only shorter results than current cmd + if [[ $cheaper == true ]]; then + cmdLen=$(echo -n "$cmd" | wc -c) + filter="^'{0,1}.{0,$((cmdLen - 1))}=" + fi + + alias | grep -E "$filter" | grep -E "=$finder" + + if [[ $exact == true ]]; then + break # because exact case is only one + elif [[ $longer = true ]]; then + break # because above grep command already found every longer aliases during first cycle + fi + + cmd=$(sed -E 's/ {0,}[^ ]*$//' <<< "$cmd") # remove last word + done } preexec_alias-finder() { - if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then + # TODO: Remove backward compatibility (other than zstyle form) + zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then alias-finder $1 fi } diff --git a/plugins/alias-finder/tests/_output/.gitkeep b/plugins/alias-finder/tests/_output/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/alias-finder/tests/_support/.gitkeep b/plugins/alias-finder/tests/_support/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/alias-finder/tests/_support/bootstrap b/plugins/alias-finder/tests/_support/bootstrap new file mode 100644 index 000000000..01076611e --- /dev/null +++ b/plugins/alias-finder/tests/_support/bootstrap @@ -0,0 +1,2 @@ +#!/usr/bin/env zsh +# Write your bootstrap code here diff --git a/plugins/alias-finder/tests/test_run.sh b/plugins/alias-finder/tests/test_run.sh new file mode 100644 index 000000000..6b7abebb6 --- /dev/null +++ b/plugins/alias-finder/tests/test_run.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env zunit + +@setup { + load ../alias-finder.plugin.zsh + + set_git_aliases() { + unalias -a # all + alias g="git" + alias gc="git commit" + alias gcv="git commit -v" + alias gcvs="git commit -v -S" + } +} + +@test 'find aliases that contain input' { + set_git_aliases + + run alias-finder "git" + + assert "${#lines[@]}" equals 1 + assert "${lines[1]}" same_as "g=git" +} + +@test 'find aliases that contain input with whitespaces at ends' { + set_git_aliases + + run alias-finder " git " + + assert "${#lines[@]}" equals 1 + assert "${lines[1]}" same_as "g=git" +} + +@test 'find aliases that contain multiple words' { + set_git_aliases + + run alias-finder "git commit -v" + + assert "${#lines[@]}" equals 3 + assert "${lines[1]}" same_as "gcv='git commit -v'" + assert "${lines[2]}" same_as "gc='git commit'" + assert "${lines[3]}" same_as "g=git" +} + +@test 'find alias that is the same with input when --exact option is set' { + set_git_aliases + + run alias-finder -e "git" + + assert "${#lines[@]}" equals 1 + assert "${lines[1]}" same_as "g=git" +} + +@test 'find alias that is the same with multiple words input when --exact option is set' { + set_git_aliases + + run alias-finder -e "git commit -v" + + assert "${#lines[@]}" equals 1 + assert "${lines[1]}" same_as "gcv='git commit -v'" +} + +@test 'find alias that is the same with or longer than input when --longer option is set' { + set_git_aliases + + run alias-finder -l "git" + + assert "${#lines[@]}" equals 4 + assert "${lines[1]}" same_as "g=git" + assert "${lines[2]}" same_as "gc='git commit'" + assert "${lines[3]}" same_as "gcv='git commit -v'" + assert "${lines[4]}" same_as "gcvs='git commit -v -S'" +} + +@test 'find alias that is the same with or longer than multiple words input when --longer option is set' { + set_git_aliases + + run alias-finder -l "git commit -v" + + assert "${#lines[@]}" equals 2 + assert "${lines[1]}" same_as "gcv='git commit -v'" + assert "${lines[2]}" same_as "gcvs='git commit -v -S'" +} + +@test 'find aliases including expensive (longer) than input' { + set_git_aliases + alias expensiveCommands="git commit" + + run alias-finder "git commit -v" + + assert "${#lines[@]}" equals 4 + assert "${lines[1]}" same_as "gcv='git commit -v'" + assert "${lines[2]}" same_as "expensiveCommands='git commit'" + assert "${lines[3]}" same_as "gc='git commit'" + assert "${lines[4]}" same_as "g=git" +} + +@test 'find aliases excluding expensive (longer) than input when --cheap option is set' { + set_git_aliases + alias expensiveCommands="git commit" + + run alias-finder -c "git commit -v" + + assert "${#lines[@]}" equals 3 + assert "${lines[1]}" same_as "gcv='git commit -v'" + assert "${lines[2]}" same_as "gc='git commit'" + assert "${lines[3]}" same_as "g=git" +} From 03a0d5bbaedc732436b5c67b166cde954817cc2f Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 24 Aug 2023 17:20:24 +0200 Subject: [PATCH 10/36] fix(clipboard): load clipboard on usage Closes #8827 --- lib/clipboard.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 2f3b6bcad..4b37abc9b 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -100,8 +100,8 @@ function detect-clipboard() { fi } -# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set, -# which is not really an error. If the user calls them, they will attempt to redetect -# (for example, perhaps the user has now installed xclip) and then either print an error -# or proceed successfully. -detect-clipboard || true +function clipcopy clippaste { + unfunction clipcopy clippaste + detect-clipboard || true # let one retry + "$0" "$@" +} From 000be72dd0c2f668cd94b36c69e45dec7b06a23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 29 Aug 2023 10:27:36 +0200 Subject: [PATCH 11/36] fix(updater): disable `nounset` to avoid warnings (#11856) --- tools/upgrade.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 34ff3f027..f7a263d66 100755 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,4 +1,5 @@ #!/usr/bin/env zsh +set +u # disable nounset local ret=0 # exit code From bf774211916c8a9d57b2b56c7846cd0b3d91baab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Hern=C3=A1ndez?= Date: Tue, 29 Aug 2023 04:29:15 -0400 Subject: [PATCH 12/36] feat(bun): add plugin (#11859) --- plugins/bun/README.md | 20 ++++++++++++++++++++ plugins/bun/bun.plugin.zsh | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/bun/README.md create mode 100644 plugins/bun/bun.plugin.zsh diff --git a/plugins/bun/README.md b/plugins/bun/README.md new file mode 100644 index 000000000..5a312370f --- /dev/null +++ b/plugins/bun/README.md @@ -0,0 +1,20 @@ +# Bun Plugin + +This plugin sets up completion for [Bun](https://bun.sh). + +To use it, add `bun` to the plugins array in your zshrc file: + +```zsh +plugins=(... bun) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and is automatically updated when the +plugin is loaded, which is usually when you start up a new terminal emulator. + +The cache is stored at: + +- `$ZSH_CACHE_DIR/completions/_bun_` completions script diff --git a/plugins/bun/bun.plugin.zsh b/plugins/bun/bun.plugin.zsh new file mode 100644 index 000000000..9924faa84 --- /dev/null +++ b/plugins/bun/bun.plugin.zsh @@ -0,0 +1,14 @@ +# If Bun is not found, don't do the rest of the script +if (( ! $+commands[bun] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `bun`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then + typeset -g -A _comps + autoload -Uz _bun + _comps[bun]=_bun +fi + +bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &| From 2ef7c73cc884163367279e4b586136e3335b1c53 Mon Sep 17 00:00:00 2001 From: t-aswath <119417646+t-aswath@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:38:09 +0530 Subject: [PATCH 13/36] feat(web-search): add `youtube` alias (#11865) --- plugins/web-search/web-search.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index ec176dd68..fc87a3495 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -25,6 +25,7 @@ function web_search() { archive "https://web.archive.org/web/*/" scholar "https://scholar.google.com/scholar?q=" ask "https://www.ask.com/web?q=" + youtube "https://www.youtube.com/results?search_query=" ) # check whether the search engine is supported @@ -66,11 +67,12 @@ alias wolframalpha='web_search wolframalpha' alias archive='web_search archive' alias scholar='web_search scholar' alias ask='web_search ask' +alias youtube='web_search youtube' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' alias news='web_search duckduckgo \!n' -alias youtube='web_search duckduckgo \!yt' +#alias youtube='web_search duckduckgo \!yt' alias map='web_search duckduckgo \!m' alias image='web_search duckduckgo \!i' alias ducky='web_search duckduckgo \!' From ccce2e1cfdf5b9680f691a402e288d9cf6ce272a Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Thu, 31 Aug 2023 15:35:33 -0600 Subject: [PATCH 14/36] fix(termsupport): match all `foot`-like terminfo (#11868) --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 6d969503d..a800e651f 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -17,7 +17,7 @@ function title { : ${2=$1} case "$TERM" in - cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot|contour*) + cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*) print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]1;${1:q}\a" # set tab name ;; From 0dc40e88a3f5bbe2607d958b5f0bf79e9df0c118 Mon Sep 17 00:00:00 2001 From: not pua <140790944+im-notpua@users.noreply.github.com> Date: Sat, 2 Sep 2023 11:46:59 +0000 Subject: [PATCH 15/36] feat(battery): add support for OpenBSD (#11872) --- plugins/battery/battery.plugin.zsh | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index db5eeb93a..1d3d529a3 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -13,6 +13,10 @@ # Author: Avneet Singh (kalsi-avneet) # # Modified to add support for Android # ########################################### +# Author: Not Pua (im-notpua) # +# Modified to add support for OpenBSD # +########################################### + if [[ "$OSTYPE" = darwin* ]]; then function battery_is_charging() { @@ -139,6 +143,46 @@ elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} ) echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" fi } +elif [[ "$OSTYPE" = openbsd* ]]; then + function battery_is_charging() { + [[ $(apm -b) -eq 3 ]] + } + function battery_pct() { + apm -l + } + function battery_pct_remaining() { + if ! battery_is_charging; then + battery_pct + else + echo "External Power" + fi + } + function battery_time_remaining() { + local remaining_time + remaining_time=$(apm -m) + if [[ $remaining_time -ge 0 ]]; then + ((hour = $remaining_time / 60 )) + ((minute = $remaining_time % 60 )) + printf %02d:%02d $hour $minute + fi + } + function battery_pct_prompt() { + local battery_pct color + battery_pct=$(battery_pct_remaining) + if battery_is_charging; then + echo "∞" + else + if [[ $battery_pct -gt 50 ]]; then + color='green' + elif [[ $battery_pct -gt 20 ]]; then + color='yellow' + else + color='red' + fi + echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" + fi + } + elif [[ "$OSTYPE" = linux* ]]; then function battery_is_charging() { if (( $+commands[acpitool] )); then From 1f56f2bdc455f2167c10fdbeca10934f5f0cbd99 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 3 Sep 2023 23:08:19 +0800 Subject: [PATCH 16/36] fix(extract): remove extraction file extension for tar (#11873) --- plugins/extract/extract.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 513950f33..88d8b0740 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -30,6 +30,11 @@ EOF local file="$1" full_path="${1:A}" local extract_dir="${1:t:r}" + # Remove the .tar extension if the file name is .tar.* + if [[ $extract_dir =~ '\.tar$' ]]; then + extract_dir="${extract_dir:r}" + fi + # 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 From 2b1303a728afc285cc13a6710de128a050500f1e Mon Sep 17 00:00:00 2001 From: n0tr00t <106423923+0x020B@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:38:32 +0000 Subject: [PATCH 17/36] feat(tmux): allow all standard config files (#11103) Closes #11803 Co-authored-by: n0tr00t <106423923+n0tr00teuorg@users.noreply.github.com> --- plugins/tmux/README.md | 26 +++++++++++++------------- plugins/tmux/tmux.plugin.zsh | 9 +++++++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 7348f77c9..0f8473daf 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -28,16 +28,16 @@ The plugin also supports the following: ## Configuration Variables -| Variable | Description | -| ----------------------------------- | ----------------------------------------------------------------------------- | -| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | -| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | -| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | -| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | -| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | -| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | -| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | -| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | -| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) | -| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | -| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | +| Variable | Description | +| ----------------------------------- | ------------------------------------------------------------------------------------------- | +| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | +| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | +| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | +| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | +| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | +| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | +| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | +| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | +| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) | +| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | +| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 311c2e6a9..680f72598 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -26,12 +26,17 @@ fi # systems without the proper terminfo : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color} # Set the configuration path -: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} +if [[ -e $HOME/.tmux.conf ]]; then + : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} +elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then + : ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf} +else + : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} +fi # Set -u option to support unicode : ${ZSH_TMUX_UNICODE:=false} # ALIASES - alias ta='tmux attach -t' alias tad='tmux attach -d -t' alias ts='tmux new-session -s' From f694d5ecc9aa45f4c394d2e15bf2bfde96eeeda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Pu=C5=A1k=C3=A1r?= <93598525+puskarpeter@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:17:28 +0200 Subject: [PATCH 18/36] feat(qodana): add completion plugin (#11813) --- plugins/qodana/README.md | 20 ++++++++++++++++++++ plugins/qodana/qodana.plugin.zsh | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/qodana/README.md create mode 100644 plugins/qodana/qodana.plugin.zsh diff --git a/plugins/qodana/README.md b/plugins/qodana/README.md new file mode 100644 index 000000000..0b68bdecf --- /dev/null +++ b/plugins/qodana/README.md @@ -0,0 +1,20 @@ +# JetBrains Qodana CLI plugin + +This plugin adds completion for the [JetBrains Qodana CLI](https://github.com/JetBrains/qodana-cli). + +To use it, add `qodana` to the plugins array in your zshrc file: + +```zsh +plugins=(... qodana) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and is automatically updated when the +plugin is loaded, which is usually when you start up a new terminal emulator. + +The cache is stored at: + +- `$ZSH_CACHE_DIR/completions/_qodana` completions script diff --git a/plugins/qodana/qodana.plugin.zsh b/plugins/qodana/qodana.plugin.zsh new file mode 100644 index 000000000..2b92a8051 --- /dev/null +++ b/plugins/qodana/qodana.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the JetBrains Qodana CLI (qodana). +if (( ! $+commands[qodana] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `qodana`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_qodana" ]]; then + typeset -g -A _comps + autoload -Uz _qodana + _comps[qodana]=_qodana +fi + +qodana completion zsh >| "$ZSH_CACHE_DIR/completions/_qodana" &| From 1abc1d998a71efd50af30210e26bee462496e442 Mon Sep 17 00:00:00 2001 From: Oscar Lee-Vermeren Date: Mon, 4 Sep 2023 13:21:27 -0400 Subject: [PATCH 19/36] feat(git-commit): create plugin (#9646) Co-authored-by: K. Akatsuki --- plugins/git-commit/README.md | 36 ++++++++++++++++++++++++ plugins/git-commit/git-commit.plugin.zsh | 23 +++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 plugins/git-commit/README.md create mode 100644 plugins/git-commit/git-commit.plugin.zsh diff --git a/plugins/git-commit/README.md b/plugins/git-commit/README.md new file mode 100644 index 000000000..dc10d8ad5 --- /dev/null +++ b/plugins/git-commit/README.md @@ -0,0 +1,36 @@ +# git-commit plugin + +The git-commit plugin adds several [git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages. + +To use it, add `git-commit` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-commit) +``` + +## Syntax + +```zshrc +git [(-s, --scope) ""] "" +``` + +> ⚠️ Single/Double quotes around the scope and message are required + +Where `type` is one of the following: + +- `build` +- `chore` +- `ci` +- `docs` +- `feat` +- `fix` +- `perf` +- `refactor` +- `revert` +- `style` +- `test` + +## Examples + +`git style "remove trailing whitespace"` -> `git commit -m "style: remove trailing whitespace"` +`git fix -s "router" "correct redirect link"` -> `git commit -m "fix(router): correct redirect link"` diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh new file mode 100644 index 000000000..70d541f21 --- /dev/null +++ b/plugins/git-commit/git-commit.plugin.zsh @@ -0,0 +1,23 @@ +_register() { + if ! git config --global --get-all alias.$1 &>/dev/null; then + git config --global alias.$1 '!a() { if [[ "$1" == "-s" || "$1" == "--scope" ]]; then git commit -m "'$1'(${2}): ${@:3}"; else git commit -m "'$1': ${@}"; fi }; a' + fi +} + +aliases=( + 'build' + 'chore' + 'ci' + 'docs' + 'feat' + 'fix' + 'perf' + 'refactor' + 'revert' + 'style' + 'test' +) + +for alias in "${aliases[@]}"; do + _register $alias +done \ No newline at end of file From 30f0d591881713c4efd1482511943abca5103927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 4 Sep 2023 19:32:38 +0200 Subject: [PATCH 20/36] fix(init): exit gracefully if on non-zsh emulation mode (#11874) Fixes #11686 --- oh-my-zsh.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 40f13f37e..137ca3b6f 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,14 +1,14 @@ +# ANSI formatting function (\033[m) +# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow +omz_f() { + [ $# -gt 0 ] || return + IFS=";" printf "\033[%sm" $* +} +# If stdout is not a terminal ignore all formatting +[ -t 1 ] || omz_f() { :; } + # Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here) [ -n "$ZSH_VERSION" ] || { - # ANSI formatting function (\033[m) - # 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow - omz_f() { - [ $# -gt 0 ] || return - IFS=";" printf "\033[%sm" $* - } - # If stdout is not a terminal ignore all formatting - [ -t 1 ] || omz_f() { :; } - omz_ptree() { # Get process tree of the current process pid=$$; pids="$pid" @@ -38,6 +38,15 @@ return 1 } +# Check if in emulation mode, if so early return +# https://github.com/ohmyzsh/ohmyzsh/issues/11686 +[[ "$(emulate)" = zsh ]] || { + printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded in \`$(emulate)\` emulation mode.$(omz_f 0)\n" >&2 + return 1 +} + +unset -f omz_f + # If ZSH is not defined, use the current script's directory. [[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}" From c74f2a1be980c60d937046364db0c9497187457a Mon Sep 17 00:00:00 2001 From: Tjark <16938041+tjarbo@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:43:06 +0200 Subject: [PATCH 21/36] feat(podman): add plugin (#11695) Closes #7489 Closes #9721 --- plugins/podman/README.md | 47 ++++++++++++++++++++++++++++++++ plugins/podman/podman.plugin.zsh | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 plugins/podman/README.md create mode 100644 plugins/podman/podman.plugin.zsh diff --git a/plugins/podman/README.md b/plugins/podman/README.md new file mode 100644 index 000000000..99daa28cd --- /dev/null +++ b/plugins/podman/README.md @@ -0,0 +1,47 @@ +# Podman plugin + +This plugin adds auto-completion and aliases for [podman](https://podman.io/). + +To use it add `podman` to the plugins array in your zshrc file. + +```zsh +plugins=(... podman) +``` + +## Aliases + +| Alias | Command | Description | +| :------ | :-------------------------------------------- | :--------------------------------------------------------------------------------------- | +| pbl | `podman build` | Build an image from a Dockerfile | +| pcin | `podman container inspect` | Display detailed information on one or more containers | +| pcls | `podman container ls` | List all the running podman containers | +| pclsa | `podman container ls --all` | List all running and stopped containers | +| pib | `podman image build` | Build an image from a Dockerfile (same as podman build) | +| pii | `podman image inspect` | Display detailed information on one or more images | +| pils | `podman image ls` | List podman images | +| pipu | `podman image push` | Push an image or repository to a remote registry | +| pirm | `podman image rm` | Remove one or more images | +| pit | `podman image tag` | Add a name and tag to a particular image | +| plo | `podman container logs` | Fetch the logs of a podman container | +| pnc | `podman network create` | Create a new network | +| pncn | `podman network connect` | Connect a container to a network | +| pndcn | `podman network disconnect` | Disconnect a container from a network | +| pni | `podman network inspect` | Return information about one or more networks | +| pnls | `podman network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | +| pnrm | `podman network rm` | Remove one or more networks | +| ppo | `podman container port` | List port mappings or a specific mapping for the container | +| ppu | `podman pull` | Pull an image or a repository from a registry | +| pr | `podman container run` | Create a new container and start it using the specified command | +| prit | `podman container run --interactive --tty` | Create a new container and start it in an interactive shell | +| prm | `podman container rm` | Remove the specified container(s) | +| prm! | `podman container rm --force` | Force the removal of a running container (uses SIGKILL) | +| pst | `podman container start` | Start one or more stopped containers | +| prs | `podman container restart` | Restart one or more containers | +| psta | `podman stop $(podman ps -q)` | Stop all running containers | +| pstp | `podman container stop` | Stop one or more running containers | +| ptop | `podman top` | Display the running processes of a container | +| pvi | `podman volume inspect` | Display detailed information about one or more volumes | +| pvls | `podman volume ls` | List all the volumes known to podman | +| pvprune | `podman volume prune` | Cleanup dangling volumes | +| pxc | `podman container exec` | Run a new command in a running container | +| pxcit | `podman container exec --interactive --tty` | Run a new command in a running container in an interactive shell | diff --git a/plugins/podman/podman.plugin.zsh b/plugins/podman/podman.plugin.zsh new file mode 100644 index 000000000..97cf92b2a --- /dev/null +++ b/plugins/podman/podman.plugin.zsh @@ -0,0 +1,47 @@ +if (( ! $+commands[podman] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `podman`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_podman" ]]; then + typeset -g -A _comps + autoload -Uz _podman + _comps[podman]=_podman +fi + +podman completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_podman" &| + +alias pbl='podman build' +alias pcin='podman container inspect' +alias pcls='podman container ls' +alias pclsa='podman container ls --all' +alias pib='podman image build' +alias pii='podman image inspect' +alias pils='podman image ls' +alias pipu='podman image push' +alias pirm='podman image rm' +alias pit='podman image tag' +alias plo='podman container logs' +alias pnc='podman network create' +alias pncn='podman network connect' +alias pndcn='podman network disconnect' +alias pni='podman network inspect' +alias pnls='podman network ls' +alias pnrm='podman network rm' +alias ppo='podman container port' +alias ppu='podman pull' +alias pr='podman container run' +alias prit='podman container run --interactive --tty' +alias prm='podman container rm' +alias 'prm!'='podman container rm --force' +alias pst='podman container start' +alias prs='podman container restart' +alias psta='podman stop $(podman ps --quiet)' +alias pstp='podman container stop' +alias ptop='podman top' +alias pvi='podman volume inspect' +alias pvls='podman volume ls' +alias pvprune='podman volume prune' +alias pxc='podman container exec' +alias pxcit='podman container exec --interactive --tty' From bae577d6b2eb621fedc994d6309b6f819855c2f8 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 5 Sep 2023 11:41:50 +0100 Subject: [PATCH 22/36] fix(git)!: remove `-b` from `blame` alias (#11864) --- 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 c3e6dd27d..44ed6f320 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -34,7 +34,7 @@ plugins=(... git) | gbsg | git bisect good | | gbsr | git bisect reset | | gbss | git bisect start | -| gbl | git blame -b -w | +| gbl | git blame -w | | gb | git branch | | gba | git branch --all | | gbd | git branch --delete | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 8886aac6d..e20373de5 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -115,7 +115,7 @@ alias gbsb='git bisect bad' alias gbsg='git bisect good' alias gbsr='git bisect reset' alias gbss='git bisect start' -alias gbl='git blame -b -w' +alias gbl='git blame -w' alias gb='git branch' alias gba='git branch --all' alias gbd='git branch --delete' From 8e8ec1348b3d4ae5fa156e26c07040ade461c83a Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 6 Sep 2023 10:54:11 +0200 Subject: [PATCH 23/36] fix(git-commit): avoid conflict with `aliases` var Closes #11876 --- plugins/git-commit/git-commit.plugin.zsh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh index 70d541f21..2ac8aa5f4 100644 --- a/plugins/git-commit/git-commit.plugin.zsh +++ b/plugins/git-commit/git-commit.plugin.zsh @@ -1,10 +1,11 @@ -_register() { - if ! git config --global --get-all alias.$1 &>/dev/null; then +function _git_commit_register { + if ! git config --global --get-all alias.$1 >/dev/null 2>&1; then git config --global alias.$1 '!a() { if [[ "$1" == "-s" || "$1" == "--scope" ]]; then git commit -m "'$1'(${2}): ${@:3}"; else git commit -m "'$1': ${@}"; fi }; a' fi } -aliases=( +local -a _git_commit_aliases +_git_commit_aliases=( 'build' 'chore' 'ci' @@ -18,6 +19,9 @@ aliases=( 'test' ) -for alias in "${aliases[@]}"; do - _register $alias -done \ No newline at end of file +for _alias in "${_git_commit_aliases[@]}"; do + _git_commit_register $_alias +done + +unfunction _git_commit_register +unset _alias From 76e541a3fe71075c8ef75ecf44cd60f17b5292bb Mon Sep 17 00:00:00 2001 From: Felipe Gallois Date: Wed, 6 Sep 2023 10:18:36 +0100 Subject: [PATCH 24/36] feat(gallois): big rewrite to `gallois` theme (#11867) --- themes/gallois.zsh-theme | 136 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 126 insertions(+), 10 deletions(-) diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme index bb97bfb17..3fc349072 100644 --- a/themes/gallois.zsh-theme +++ b/themes/gallois.zsh-theme @@ -1,24 +1,140 @@ # Depends on the git plugin for work_in_progress() (( $+functions[work_in_progress] )) || work_in_progress() {} -ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" -ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}[%{$fg[green]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[cyan]%}]" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_CLEAN="" # Customized git status, oh-my-zsh currently does not allow render dirty status before branch git_custom_status() { local branch=$(git_current_branch) [[ -n "$branch" ]] || return 0 - echo "$(parse_git_dirty)\ -%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\ -${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}" + print "%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\ +${ZSH_THEME_GIT_PROMPT_PREFIX}$(parse_git_dirty)${branch}\ +${ZSH_THEME_GIT_PROMPT_SUFFIX}" +} +autoload -U colors && colors + +#export VCS_PROMPT=hg_prompt_info +export VCS_PROMPT=git_custom_status + +base_prompt="%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b " +custom_prompt="" +last_run_time="" +last_vcs_info="" + + +function pipestatus_parse { + PIPESTATUS="$pipestatus" + ERROR=0 + for i in "${(z)PIPESTATUS}"; do + if [[ "$i" -ne 0 ]]; then + ERROR=1 + fi + done + + if [[ "$ERROR" -ne 0 ]]; then + print "[%{$fg[red]%}$PIPESTATUS%{$fg[cyan]%}]" + fi } -# RVM component of prompt -ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}[" -ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}" # Combine it all into a final right-side prompt -RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}" PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' +function preexec() { + last_run_time=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time') +} + +function duration() { + local duration + local now=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time') + local last=$1 + local last_split=("${(@s/./)last}") + local now_split=("${(@s/./)now}") + local T=$((now_split[1] - last_split[1])) + local D=$((T/60/60/24)) + local H=$((T/60/60%24)) + local M=$((T/60%60)) + local S=$((T%60)) + local s=$(((now_split[2] - last_split[2]) / 1000000000.)) + local m=$(((now_split[2] - last_split[2]) / 1000000.)) + + (( $D > 0 )) && duration+="${D}d" + (( $H > 0 )) && duration+="${H}h" + (( $M > 0 )) && duration+="${M}m" + + if [[ $S -le 0 ]]; then + printf "%ims" "$m" + else + if ! [[ -z $duration ]] && printf "%s" "$duration" + local sec_milli=$((S + s)) + printf "%.3fs" "$sec_milli" + fi +} + +function precmd() { + RETVAL=$(pipestatus_parse) + local info="" + + if [ ! -z "$last_run_time" ]; then + local elapsed=$(duration $last_run_time) + last_run_time=$(print $last_run_time | tr -d ".") + if [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 120 * 1000 * 1000 * 1000 )) ]; then + local elapsed_color="%{$fg[magenta]%}" + elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 60 * 1000 * 1000 * 1000 )) ]; then + local elapsed_color="%{$fg[red]%}" + elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 10 * 1000 * 1000 * 1000 )) ]; then + local elapsed_color="%{$fg[yellow]%}" + else + local elapsed_color="%{$fg[green]%}" + fi + info=$(printf "%s%s%s%s%s" "%{$fg[cyan]%}[" "$elapsed_color" "$elapsed" "%{$fg[cyan]%}]" "$RETVAL") + unset last_run_time + fi + + if [ -z "$info" -a ! -z "$last_vcs_info" ]; then + custom_prompt="$last_vcs_info$base_prompt" + return; + fi + + if (( ${+VCS_PROMPT} )); then + last_vcs_info=$($VCS_PROMPT) + if [ ! -z "$last_vcs_info" ]; then + [ -z "$info" ] && info=$last_vcs_info || info="$info$last_vcs_info" + fi + fi + + [ -z "$info" ] && custom_prompt="$base_prompt" || custom_prompt="$info$base_prompt" +} + +function hg_prompt_info() { + unset output info parts branch_parts branch + + local output="" + if ! output="$(hg status 2> /dev/null)"; then + return + fi + + local info=$(hg log -l1 --template '{author}:{node|short}:{remotenames}:{phabdiff}') + local parts=(${(@s/:/)info}) + local branch_parts=(${(@s,/,)parts[3]}) + local branch=${branch_parts[-1]} + [ ! -z "${parts[3]}" ] && [[ "${parts[1]}" =~ "$USER@" ]] && branch=${parts[3]} + [ -z "${parts[3]}" ] && branch=${parts[2]} + + if [[ ! -z "$output" ]]; then + local color="%{$fg[red]%}" + elif [[ "${branch}" == "master" || "${branch}" == "warm" ]]; then + local color="%{$fg[yellow]%}" + else + local color="%{$fg[green]%}" + fi + + print "%{$fg[cyan]%}[${color}${branch}%{$fg[cyan]%}]" +} + +setopt PROMPT_SUBST +PROMPT='$custom_prompt' + + From 331f3c8b2e28e47af41ae309aa814dab524a3374 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 6 Sep 2023 11:36:57 +0100 Subject: [PATCH 25/36] feat(git): add bisect aliases `gbsn` and `gbso` (#11869) --- plugins/git/README.md | 2 ++ plugins/git/git.plugin.zsh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 44ed6f320..922cbee55 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -32,6 +32,8 @@ plugins=(... git) | gbs | git bisect | | gbsb | git bisect bad | | gbsg | git bisect good | +| gbsn | git bisect new | +| gbso | git bisect old | | gbsr | git bisect reset | | gbss | git bisect start | | gbl | git blame -w | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index e20373de5..4afe34e99 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -113,6 +113,8 @@ alias gapt='git apply --3way' alias gbs='git bisect' alias gbsb='git bisect bad' alias gbsg='git bisect good' +alias gbsn='git bisect new' +alias gbso='git bisect old' alias gbsr='git bisect reset' alias gbss='git bisect start' alias gbl='git blame -w' From 6a7aab47dd6071b7f264477195b06efb7e7bd480 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 6 Sep 2023 11:42:09 +0100 Subject: [PATCH 26/36] docs(git): align markdown table borders (#11878) --- plugins/git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 922cbee55..6eb63ea40 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -36,7 +36,7 @@ plugins=(... git) | gbso | git bisect old | | gbsr | git bisect reset | | gbss | git bisect start | -| gbl | git blame -w | +| gbl | git blame -w | | gb | git branch | | gba | git branch --all | | gbd | git branch --delete | From 079dbff2c4f22935a71101c511e2285327d8ab68 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 6 Sep 2023 19:01:41 +0200 Subject: [PATCH 27/36] feat(pipenv): add option to disable auto shell feature Closes #11472 --- plugins/pipenv/README.md | 15 ++++++++++++- plugins/pipenv/pipenv.plugin.zsh | 38 +++++++++++++++++--------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md index 4329feb32..e78ef0e3b 100644 --- a/plugins/pipenv/README.md +++ b/plugins/pipenv/README.md @@ -1,6 +1,7 @@ # Pipenv ## Installation + In your `.zshrc` file, add `pipenv` to the plugins section ``` @@ -8,7 +9,9 @@ plugins=(... pipenv ...) ``` ## Features -This plugin provides some features to simplify the use of Pipenv while working on ZSH. + +This plugin provides some features to simplify the use of Pipenv while working on ZSH. + - Adds completion for pipenv - Auto activates and deactivates pipenv shell - Adds short aliases for common pipenv commands @@ -27,3 +30,13 @@ This plugin provides some features to simplify the use of Pipenv while working o - `pwh` is aliased to `pipenv --where` - `pvenv` is aliased to `pipenv --venv` - `ppy` is aliased to `pipenv --py` + +## Configuration + +### Shell activation + +If you want to disable the shell activation and deactivation feature, add the following style to your `.zshrc` before sourcing `oh-my-zsh.sh`: + +```zsh +zstyle ':omz:plugins:pipenv' auto-shell no +``` diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 22d1a3131..f81c266a4 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -12,28 +12,30 @@ fi _PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &| -# Automatic pipenv shell activation/deactivation -_togglePipenvShell() { - # deactivate shell if Pipfile doesn't exist and not in a subdir - if [[ ! -f "$PWD/Pipfile" ]]; then - if [[ "$PIPENV_ACTIVE" == 1 ]]; then - if [[ "$PWD" != "$pipfile_dir"* ]]; then - exit +if zstyle -T ':omz:plugins:pipenv' auto-shell; then + # Automatic pipenv shell activation/deactivation + _togglePipenvShell() { + # deactivate shell if Pipfile doesn't exist and not in a subdir + if [[ ! -f "$PWD/Pipfile" ]]; then + if [[ "$PIPENV_ACTIVE" == 1 ]]; then + if [[ "$PWD" != "$pipfile_dir"* ]]; then + exit + fi fi fi - fi - # activate the shell if Pipfile exists - if [[ "$PIPENV_ACTIVE" != 1 ]]; then - if [[ -f "$PWD/Pipfile" ]]; then - export pipfile_dir="$PWD" - pipenv shell + # activate the shell if Pipfile exists + if [[ "$PIPENV_ACTIVE" != 1 ]]; then + if [[ -f "$PWD/Pipfile" ]]; then + export pipfile_dir="$PWD" + pipenv shell + fi fi - fi -} -autoload -U add-zsh-hook -add-zsh-hook chpwd _togglePipenvShell -_togglePipenvShell + } + autoload -U add-zsh-hook + add-zsh-hook chpwd _togglePipenvShell + _togglePipenvShell +fi # Aliases alias pch="pipenv check" From b07c8cfe692bc6c7702f0aef5d493b12dfb43392 Mon Sep 17 00:00:00 2001 From: Haltarys <45515869+Haltarys@users.noreply.github.com> Date: Sun, 10 Sep 2023 09:28:33 +0200 Subject: [PATCH 28/36] fix(git-commit): fix compatibility of alias functions (#11883) --- plugins/git-commit/git-commit.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh index 2ac8aa5f4..4ad4c0177 100644 --- a/plugins/git-commit/git-commit.plugin.zsh +++ b/plugins/git-commit/git-commit.plugin.zsh @@ -1,6 +1,6 @@ function _git_commit_register { if ! git config --global --get-all alias.$1 >/dev/null 2>&1; then - git config --global alias.$1 '!a() { if [[ "$1" == "-s" || "$1" == "--scope" ]]; then git commit -m "'$1'(${2}): ${@:3}"; else git commit -m "'$1': ${@}"; fi }; a' + git config --global alias.$1 '!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$1'(${scope}): ${@}"; else git commit -m "'$1': ${@}"; fi }; a' fi } From cd18bce53e01d0f614ffcbb7429053fb508cb095 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Mon, 11 Sep 2023 03:31:53 -0400 Subject: [PATCH 29/36] feat(mortalscumbag): show toolbox info (#11884) --- themes/mortalscumbag.zsh-theme | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index d81a7ca06..36301cb76 100644 --- a/themes/mortalscumbag.zsh-theme +++ b/themes/mortalscumbag.zsh-theme @@ -51,8 +51,14 @@ function ssh_connection() { fi } +function _toolbox_prompt_info() { + if typeset -f toolbox_prompt_info > /dev/null; then + toolbox_prompt_info + fi +} + local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}" -PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# ' +PROMPT=$'\n$(_toolbox_prompt_info)$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# ' ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}" From 7077989d28e9cd723afcb4355874683d847278b4 Mon Sep 17 00:00:00 2001 From: Samuel Beckley Date: Mon, 11 Sep 2023 03:35:28 -0400 Subject: [PATCH 30/36] feat(macos): update spotify plugin to upstream (#11534) --- plugins/macos/spotify | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/plugins/macos/spotify b/plugins/macos/spotify index 5fb40517c..ae42db425 100644 --- a/plugins/macos/spotify +++ b/plugins/macos/spotify @@ -1,7 +1,7 @@ #!/usr/bin/env bash function spotify() { -# Copyright (c) 2012--2019 Harish Narayanan +# Copyright (c) 2012--2023 Harish Narayanan # # Contains numerous helpful contributions from Jorge Colindres, Thomas # Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin @@ -35,6 +35,9 @@ if ! [[ -f "${USER_CONFIG_FILE}" ]]; then fi source "${USER_CONFIG_FILE}"; +# Set the percent change in volume for vol up and vol down +VOL_INCREMENT=10 + showAPIHelp() { echo; echo "Connecting to Spotify's API:"; @@ -170,12 +173,12 @@ while [ $# -gt 0 ]; do if [ -z "${CLIENT_ID}" ]; then cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}"; showAPIHelp; - return 1 + return 1; fi if [ -z "${CLIENT_SECRET}" ]; then cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}"; showAPIHelp; - return 1 + return 1; fi SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r'); SPOTIFY_PLAY_URI=""; @@ -198,7 +201,7 @@ while [ $# -gt 0 ]; do fi SPOTIFY_ACCESS_TOKEN=$( \ printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \ - | grep -E -o '"access_token":".*",' \ + | command grep -E -o '"access_token":".*",' \ | sed 's/"access_token"://g' \ | sed 's/"//g' \ | sed 's/,.*//g' \ @@ -219,9 +222,8 @@ while [ $# -gt 0 ]; do -H "Accept: application/json" \ --data-urlencode "q=$Q" \ -d "type=$type&limit=1&offset=0" \ - | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1 + | command grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1 ) - echo "play uri: ${SPOTIFY_PLAY_URI}" } case $2 in @@ -235,11 +237,11 @@ while [ $# -gt 0 ]; do results=$( \ curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \ - | grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \ + | command grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \ ) count=$( \ - echo "$results" | grep -c "spotify:playlist" \ + echo "$results" | command grep -c "spotify:playlist" \ ) if [ "$count" -gt 0 ]; then @@ -333,16 +335,16 @@ while [ $# -gt 0 ]; do cecho "Current Spotify volume level is $vol."; break ; elif [ "$2" = "up" ]; then - if [ $vol -le 90 ]; then - newvol=$(( vol+10 )); + if [ $vol -le $(( 100-$VOL_INCREMENT )) ]; then + newvol=$(( vol+$VOL_INCREMENT )); cecho "Increasing Spotify volume to $newvol."; else newvol=100; cecho "Spotify volume level is at max."; fi elif [ "$2" = "down" ]; then - if [ $vol -ge 10 ]; then - newvol=$(( vol-10 )); + if [ $vol -ge $(( $VOL_INCREMENT )) ]; then + newvol=$(( vol-$VOL_INCREMENT )); cecho "Reducing Spotify volume to $newvol."; else newvol=0; @@ -354,11 +356,11 @@ while [ $# -gt 0 ]; do else echo "Improper use of 'vol' command" echo "The 'vol' command should be used as follows:" - echo " vol up # Increases the volume by 10%."; - echo " vol down # Decreases the volume by 10%."; + echo " vol up # Increases the volume by $VOL_INCREMENT%."; + echo " vol down # Decreases the volume by $VOL_INCREMENT%."; echo " vol [amount] # Sets the volume to an amount between 0 and 100."; echo " vol # Shows the current Spotify volume."; - return 1 + return 1; fi osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; @@ -468,10 +470,9 @@ while [ $# -gt 0 ]; do "help" ) showHelp; break ;; - * ) showHelp; - return 1 ;; + return 1; esac done From 38ef5192cb1c43159b516d15ab8fed96f847b36b Mon Sep 17 00:00:00 2001 From: Felipe Gallois Date: Mon, 11 Sep 2023 10:05:50 +0100 Subject: [PATCH 31/36] feat(oldgalois): add theme (#11880) Closes #11879 --- themes/oldgallois.zsh-theme | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 themes/oldgallois.zsh-theme diff --git a/themes/oldgallois.zsh-theme b/themes/oldgallois.zsh-theme new file mode 100644 index 000000000..bb97bfb17 --- /dev/null +++ b/themes/oldgallois.zsh-theme @@ -0,0 +1,24 @@ +# Depends on the git plugin for work_in_progress() +(( $+functions[work_in_progress] )) || work_in_progress() {} + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" +ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +# Customized git status, oh-my-zsh currently does not allow render dirty status before branch +git_custom_status() { + local branch=$(git_current_branch) + [[ -n "$branch" ]] || return 0 + echo "$(parse_git_dirty)\ +%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\ +${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}" +} + +# RVM component of prompt +ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}[" +ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}" + +# Combine it all into a final right-side prompt +RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}" +PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' From 01f55123118601a935f28ff6c49e625448bdd32d Mon Sep 17 00:00:00 2001 From: bretello Date: Tue, 12 Sep 2023 21:41:07 +0200 Subject: [PATCH 32/36] feat(systemd): add alias for --failed commands (#11847) --- plugins/systemd/README.md | 1 + plugins/systemd/systemd.plugin.zsh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/systemd/README.md b/plugins/systemd/README.md index ffa0567a8..755c649a1 100644 --- a/plugins/systemd/README.md +++ b/plugins/systemd/README.md @@ -12,6 +12,7 @@ plugins=(... systemd) | Alias | Command | Description | |:-----------------------|:-----------------------------------|:-----------------------------------------------------------------| +| `sc-failed` | `systemctl --failed` | List failed systemd units | | `sc-list-units` | `systemctl list-units` | List all units systemd has in memory | | `sc-is-active` | `systemctl is-active` | Show whether a unit is active | | `sc-status` | `systemctl status` | Show terse runtime status information about one or more units | diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 1270bea0e..382a57b29 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -93,6 +93,9 @@ alias scu-enable-now="scu-enable --now" alias scu-disable-now="scu-disable --now" alias scu-mask-now="scu-mask --now" +# --failed commands +alias scu-failed='systemctl --user --failed' +alias sc-failed='systemctl --failed' function systemd_prompt_info { local unit From 7e4c26860d74a01cd6d91fd10fcc28fccd740ddd Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 13 Sep 2023 10:48:16 +0200 Subject: [PATCH 33/36] feat(brew): add support for custom `BREW_LOCATION` Fixes #11888 Co-authored-by: Matt Cable --- plugins/brew/README.md | 20 +++++++++++--------- plugins/brew/brew.plugin.zsh | 7 ++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 4730194bc..299393b28 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -10,10 +10,12 @@ plugins=(... brew) ## Shellenv -If `brew` is not found in the PATH, this plugin will attempt to find it in common -locations, and execute `brew shellenv` to set the environment appropriately. -This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously -defined for convenience. +If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute +`brew shellenv` to set the environment appropriately. This plugin will also export +`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience. + +In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to +the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment. ## Aliases @@ -33,9 +35,9 @@ defined for convenience. ## Completion -This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh. +This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it +manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh. -With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the -brew installation, so we no longer ship it with the brew plugin; now it only has brew -aliases. If you find that brew completion no longer works, make sure you have your Homebrew -installation fully up to date. +With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation, +so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion +no longer works, make sure you have your Homebrew installation fully up to date. diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index b52664a39..447036376 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,5 +1,10 @@ if (( ! $+commands[brew] )); then - if [[ -x /opt/homebrew/bin/brew ]]; then + if [[ -n "$BREW_LOCATION" ]]; then + if [[ ! -x "$BREW_LOCATION" ]]; then + echo "[oh-my-zsh] $BREW_LOCATION is not executable" + return + fi + elif [[ -x /opt/homebrew/bin/brew ]]; then BREW_LOCATION="/opt/homebrew/bin/brew" elif [[ -x /usr/local/bin/brew ]]; then BREW_LOCATION="/usr/local/bin/brew" From 4167474f124bfc39d0e6cd612c95acf0a1ae9904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 13 Sep 2023 16:31:24 +0200 Subject: [PATCH 34/36] feat(grc): add support for arm64 macos (#11890) --- plugins/grc/grc.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh index b709b9e02..e036b8d89 100644 --- a/plugins/grc/grc.plugin.zsh +++ b/plugins/grc/grc.plugin.zsh @@ -2,8 +2,9 @@ # common grc.zsh paths files=( - /etc/grc.zsh # default - /usr/local/etc/grc.zsh # homebrew + /etc/grc.zsh # default + /usr/local/etc/grc.zsh # homebrew darwin-x64 + /opt/homebrew/etc/grc.zsh # homebrew darwin-arm64 ) # verify the file is readable and source it From bbda81fe4b338f00bbf7c7f33e6d1b12d067dc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 13 Sep 2023 19:23:41 +0200 Subject: [PATCH 35/36] fix(changelog): fix regression for unstyled code in commit subjects --- tools/changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 1af74e42d..6d768963e 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -366,7 +366,7 @@ function display-release { # In text mode, highlight (#) and dim text between `backticks` text) if supports_hyperlinks; then - sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g' <<< "$subject" + sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" else sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" fi ;; From cdd7dab5db4c668b962f908b57e244aa1ff4b574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 17 Sep 2023 16:20:46 +0200 Subject: [PATCH 36/36] ci(installer): remove `vc link` which generates the wrong project `vc link` is not needed, as we already have `VERCEL_PROJECT_ID` defined as an env variable. Currently the `vc link` only creates a second empty project with the name `installer` as seen in logs: Linked to ohmyzsh/installer (created .vercel and added it to .gitignore) Vercel CLI 32.2.4 --- .github/workflows/installer.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index ac88d10b0..4a25c8079 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -51,5 +51,4 @@ jobs: 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 }}