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! 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 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 } 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 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 + 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 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 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)" 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