From 0e7d7b87f33b5ec8c75a3a0a9b16fae082d06348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 7 Jul 2021 10:40:05 +0200 Subject: [PATCH 1/9] feat(changelog): ignore merge commits --- tools/changelog.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/changelog.sh b/tools/changelog.sh index 836afef14..56ea42cb1 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -114,6 +114,11 @@ function parse-commit { fi } + # Ignore commit if it is a merge commit + if [[ $(command git show -s --format=%p $1 | wc -w) -gt 1 ]]; then + return + fi + # Parse commit with hash $1 local hash="$1" subject body warning rhash subject="$(command git show -s --format=%s $hash)" From c44b99e901d7ef58f60247995152de1b937e2e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 28 Jun 2021 15:54:24 +0200 Subject: [PATCH 2/9] fix(dotenv): draw confirmation prompt in next empty line Without this fix the confirmation prompt appears wherever the cursor is, which means that it might appear in the command line when using a widget that changes the directory without redrawing the prompt (an example of this are the dircycle and dirhistory plugins). --- plugins/dotenv/dotenv.plugin.zsh | 66 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 24f285df5..40ec5c46f 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -11,41 +11,51 @@ ## Functions source_env() { - if [[ -f $ZSH_DOTENV_FILE ]]; then - if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then - local confirmation dirpath="${PWD:A}" + if [[ ! -f "$ZSH_DOTENV_FILE" ]]; then + return + fi - # make sure there is an (dis-)allowed file - touch "$ZSH_DOTENV_ALLOWED_LIST" - touch "$ZSH_DOTENV_DISALLOWED_LIST" + if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then + local confirmation dirpath="${PWD:A}" - # early return if disallowed - if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then - return; - fi + # make sure there is an (dis-)allowed file + touch "$ZSH_DOTENV_ALLOWED_LIST" + touch "$ZSH_DOTENV_DISALLOWED_LIST" - # check if current directory's .env file is allowed or ask for confirmation - if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then - # print same-line prompt and output newline character if necessary - echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " - read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo - - # check input - case "$confirmation" in - [nN]) return ;; - [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; - [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; - *) ;; # interpret anything else as a yes - esac - fi + # early return if disallowed + if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + return fi - # test .env syntax - zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + # check if current directory's .env file is allowed or ask for confirmation + if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then + # get cursor column and print new line before prompt if not at line beginning + local column + echo -ne "\e[6n" > /dev/tty + read -t 1 -s -d R column < /dev/tty + column="${column##*\[*;}" + [[ $column -eq 1 ]] || echo - setopt localoptions allexport - source $ZSH_DOTENV_FILE + # print same-line prompt and output newline character if necessary + echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " + read -k 1 confirmation + [[ "$confirmation" = $'\n' ]] || echo + + # check input + case "$confirmation" in + [nN]) return ;; + [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; + [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; + *) ;; # interpret anything else as a yes + esac + fi fi + + # test .env syntax + zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + + setopt localoptions allexport + source $ZSH_DOTENV_FILE } autoload -U add-zsh-hook From 36f444ed7325720ec05f182781ec7d6c9a4d675c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 8 Jul 2021 16:11:16 +0200 Subject: [PATCH 3/9] fix(update): fix error exit code on update check (#10033) This patch removes the 'exit 1' status code when the update check finishes or is ended with CTRL+C. Fixes #10033 --- tools/check_for_upgrade.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 29a48b880..e87da3487 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -48,14 +48,17 @@ function update_ohmyzsh() { return fi - # Remove lock directory on exit. `return 1` is important for when trapping a SIGINT: + # Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT: # The return status from the function is handled specially. If it is zero, the signal is # assumed to have been handled, and execution continues normally. Otherwise, the shell # will behave as interrupted except that the return status of the trap is retained. + # This means that for a CTRL+C, the trap needs to return the same exit status so that + # the shell actually exits what it's running. trap " - unset -f current_epoch update_last_updated_file update_ohmyzsh - command rm -rf '$ZSH/log/update.lock' - return 1 + ret=\$? + unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null + command rm -rf '$ZSH/log/update.lock' + return \$ret " EXIT INT QUIT # Create or update .zsh-update file if missing or malformed From 5b4e3ee7f1c48505a3ec56ce38e444b88feda7a4 Mon Sep 17 00:00:00 2001 From: Robert Lankford Date: Mon, 12 Jul 2021 10:16:26 -0500 Subject: [PATCH 4/9] feat(gnu-utils): include ggrep in gcmds (#10044) Co-authored-by: Robert Lankford --- plugins/gnu-utils/gnu-utils.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index 23e00c295..539e7fe4d 100644 --- a/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -36,7 +36,7 @@ __gnu_utils() { gcmds+=('gfind' 'gxargs' 'glocate') # Not part of either coreutils or findutils, installed separately. - gcmds+=('gsed' 'gtar' 'gtime' 'gmake') + gcmds+=('gsed' 'gtar' 'gtime' 'gmake' 'ggrep') for gcmd in "${gcmds[@]}"; do # Do nothing if the command isn't found From e4f6f1698d4bf2cebe3fd0e2f5bae9f163780a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 12 Jul 2021 17:34:34 +0200 Subject: [PATCH 5/9] fix(copybuffer): show error below the command line --- plugins/copybuffer/copybuffer.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh index 483ed5a5f..87a658d93 100644 --- a/plugins/copybuffer/copybuffer.plugin.zsh +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -5,7 +5,7 @@ copybuffer () { if which clipcopy &>/dev/null; then printf "%s" "$BUFFER" | clipcopy else - echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." + zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly." fi } From 23f9348e2c2341df71b1891eb4607f60ddd5a204 Mon Sep 17 00:00:00 2001 From: Sergei Shvetsov Date: Tue, 13 Jul 2021 15:05:33 +0700 Subject: [PATCH 6/9] fix(aws): allow for profile switch w/o MFA configured (#9924) --- plugins/aws/aws.plugin.zsh | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index e1566b113..2d095635b 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -62,47 +62,47 @@ function acp() { read -r sess_duration fi mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}") + fi - # Now see whether we need to just MFA for the current role, or assume a different one - local role_arn="$(aws configure get role_arn --profile $profile)" - local sess_name="$(aws configure get role_session_name --profile $profile)" + # Now see whether we need to just MFA for the current role, or assume a different one + local role_arn="$(aws configure get role_arn --profile $profile)" + local sess_name="$(aws configure get role_session_name --profile $profile)" - if [[ -n "$role_arn" ]]; then - # Means we need to assume a specified role - aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}") + if [[ -n "$role_arn" ]]; then + # Means we need to assume a specified role + aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}") - # Check whether external_id is configured to use while assuming the role - local external_id="$(aws configure get external_id --profile $profile)" - if [[ -n "$external_id" ]]; then - aws_command+=(--external-id "$external_id") - fi - - # Get source profile to use to assume role - local source_profile="$(aws configure get source_profile --profile $profile)" - if [[ -z "$sess_name" ]]; then - sess_name="${source_profile:-profile}" - fi - aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}") - - echo "Assuming role $role_arn using profile ${source_profile:-profile}" - else - # Means we only need to do MFA - aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}") - echo "Obtaining session token for profile $profile" + # Check whether external_id is configured to use while assuming the role + local external_id="$(aws configure get external_id --profile $profile)" + if [[ -n "$external_id" ]]; then + aws_command+=(--external-id "$external_id") fi - # Format output of aws command for easier processing - aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) - - # Run the aws command to obtain credentials - local -a credentials - credentials=(${(ps:\t:)"$(${aws_command[@]})"}) - - if [[ -n "$credentials" ]]; then - aws_access_key_id="${credentials[1]}" - aws_secret_access_key="${credentials[2]}" - aws_session_token="${credentials[3]}" + # Get source profile to use to assume role + local source_profile="$(aws configure get source_profile --profile $profile)" + if [[ -z "$sess_name" ]]; then + sess_name="${source_profile:-profile}" fi + aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}") + + echo "Assuming role $role_arn using profile ${source_profile:-profile}" + else + # Means we only need to do MFA + aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}") + echo "Obtaining session token for profile $profile" + fi + + # Format output of aws command for easier processing + aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) + + # Run the aws command to obtain credentials + local -a credentials + credentials=(${(ps:\t:)"$(${aws_command[@]})"}) + + if [[ -n "$credentials" ]]; then + aws_access_key_id="${credentials[1]}" + aws_secret_access_key="${credentials[2]}" + aws_session_token="${credentials[3]}" fi # Switch to AWS profile From 4eadb9cf758b632b113bb793d5f1e38f4c304392 Mon Sep 17 00:00:00 2001 From: Mahdyar Hasanpour Date: Fri, 16 Jul 2021 14:11:00 +0430 Subject: [PATCH 7/9] chore: convert the repo issue templates to issue forms (#10050) --- .github/ISSUE_TEMPLATE/bug_report.md | 46 --------------- .github/ISSUE_TEMPLATE/bug_report.yml | 69 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 29 --------- .github/ISSUE_TEMPLATE/feature_request.yml | 32 ++++++++++ 4 files changed, 101 insertions(+), 75 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 88a6b814d..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve Oh My Zsh -labels: 'Bug' - ---- - - - -**Describe the bug** -A clear description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior, for example: -1. Enable this plugin '...' -2. Run command '...' or try the autocomplete command '...' -3. See error - -**Expected behavior** -A brief description of what should happen. - -**Screenshots and/or Recordings** -If applicable, add screenshots to help explain your problem. -You can also record an asciinema session: https://asciinema.org/ - -**Self Check** - -- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)? - This can help cut down on filling up issues. We always have a few people - online that are in a variety of timezones that are willing to help you! - -- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support - -**Desktop (please complete the following information):** - - - OS / Distro: [e.g. Arch Linux, macOS] - - If on Windows what version of WSL: [e.g. WSL1, WSL2] - - Latest ohmyzsh update?: [e.g. Yes/No] - - ZSH Version: [e.g. 5.6] - - Terminal emulator: [e.g. iTerm2] - -**Additional context** -Add any other context about the problem here. This can be themes, plugins, custom configs. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..af2973fec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,69 @@ +name: Bug report +description: Create a report to help us improve Oh My Zsh +labels: 'Bug' +body: + - type: markdown + attributes: + value: | + ## Self Check + - Try searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed) for similar issues. + - Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help. + - type: textarea + validations: + required: true + attributes: + label: Describe the bug + description: A clear description of what the bug is. + - type: textarea + validations: + required: true + attributes: + label: Steps to reproduce + description: | + Steps to reproduce the problem. + placeholder: | + For example: + 1. Enable plugin '...' + 2. Run command '...' or try to complete command '...' + 3. See error + - type: textarea + validations: + required: true + attributes: + label: Expected behavior + description: A brief description of what should happen. + - type: textarea + attributes: + label: Screenshots and recordings + description: | + If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ + - type: input + validations: + required: true + attributes: + label: OS / Distro + placeholder: e.g. Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... + - type: input + validations: + required: true + attributes: + label: Zsh version + description: Run `echo $ZSH_VERSION` to check. + placeholder: e.g. 5.6 + - type: input + validations: + required: true + attributes: + label: Terminal emulator + placeholder: e.g. iTerm2, Gnome Terminal... + - type: dropdown + attributes: + label: If using WSL on Windows, which version of WSL + description: Run `wsl -l -v` to check. + options: + - WSL1 + - WSL2 + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. This can be themes, plugins, custom settings... diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 788f77368..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: Feature request -about: Suggest a feature for Oh My Zsh -labels: 'Feature' - ---- - - - -**Is your feature request related to a particular plugin or theme? If so, specify it.** -The name of the plugin, theme or alias that you would like us to improve. [...] - -**Is your feature request related to a problem? Please describe.** -A description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A description of what you want to happen. [...] - -**Describe alternatives you've considered** -A description of any alternative solutions or features you've considered. This can also include other plugins or themes. - -**Additional context** -Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. - -**Related Issues** -Is there any open or closed issues that is related to this feature request? If so please link them below! [...] diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..dc4baf2b1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,32 @@ +name: Feature request +description: Suggest a feature for Oh My Zsh +labels: 'Feature' +body: + - type: input + attributes: + label: If the feature request is for a plugin or theme, specify it here. + description: The name of the plugin or theme that you would like us to improve. + placeholder: e.g. Git plugin, Agnoster theme + - type: textarea + attributes: + label: If the feature solves a problem you have, specify it here. + description: A description of what the problem is. + placeholder: Ex. I'm always frustrated when... + - type: textarea + attributes: + label: Describe the proposed feature. + description: A description of what you want to happen. Be as specific as possible. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes. + - type: textarea + attributes: + label: Additional context + description: Add any other context, screenshots or Discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. + - type: textarea + attributes: + label: Related Issues + description: Is there any open or closed issues that is related to this feature request? If so please link them below! From dac3314c76e799cddbbe5cf63870d31861626059 Mon Sep 17 00:00:00 2001 From: "MalaGaM @ ARTiSPRETiS" Date: Fri, 16 Jul 2021 11:48:19 +0200 Subject: [PATCH 8/9] chore(github): add links to supported tools (#10057) --- plugins/github/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/github/README.md b/plugins/github/README.md index 70b863f64..af2b8a4e7 100644 --- a/plugins/github/README.md +++ b/plugins/github/README.md @@ -2,8 +2,8 @@ This plugin supports working with GitHub from the command line. It provides a few things: -* Sets up the `hub` wrapper and completions for the `git` command if you have `hub` installed. -* Completion for the `github` Ruby gem. +* Sets up the `hub` wrapper and completions for the `git` command if you have [`hub`](https://github.com/github/hub) installed. +* Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem). * Convenience functions for working with repos and URLs. ### Functions From d9ad99531f74df8b0d6622feeab5e253528b43d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20=C5=A0ebenik?= Date: Fri, 23 Jul 2021 12:39:51 +0200 Subject: [PATCH 9/9] feat(plugins): add fnm plugin (#9864) Co-authored-by: Ziga Sebenik --- plugins/fnm/.gitignore | 2 ++ plugins/fnm/README.md | 9 +++++++++ plugins/fnm/fnm.plugin.zsh | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 plugins/fnm/.gitignore create mode 100644 plugins/fnm/README.md create mode 100644 plugins/fnm/fnm.plugin.zsh diff --git a/plugins/fnm/.gitignore b/plugins/fnm/.gitignore new file mode 100644 index 000000000..0b2bc9ab7 --- /dev/null +++ b/plugins/fnm/.gitignore @@ -0,0 +1,2 @@ +_fnm + diff --git a/plugins/fnm/README.md b/plugins/fnm/README.md new file mode 100644 index 000000000..00fab5cd4 --- /dev/null +++ b/plugins/fnm/README.md @@ -0,0 +1,9 @@ +# fnm plugin + +This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager. + +To use it, add `fnm` to the plugins array in your zshrc file: + +```zsh +plugins=(... fnm) +``` diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh new file mode 100644 index 000000000..5ce558dcb --- /dev/null +++ b/plugins/fnm/fnm.plugin.zsh @@ -0,0 +1,12 @@ +# COMPLETION FUNCTION +if (( $+commands[fnm] )); then + if [[ ! -f $ZSH_CACHE_DIR/fnm_version ]] \ + || [[ "$(fnm --version)" != "$(< "$ZSH_CACHE_DIR/fnm_version")" ]] \ + || [[ ! -f $ZSH/plugins/fnm/_fnm ]]; then + fnm completions --shell=zsh > $ZSH/plugins/fnm/_fnm + fnm --version > $ZSH_CACHE_DIR/fnm_version + fi + autoload -Uz _fnm + _comps[fnm]=_fnm +fi +