Merge branch 'ohmyzsh:master' into master

This commit is contained in:
Vigneshwar Ravichandar 2021-07-25 16:00:36 +05:30 committed by GitHub
commit 6cc5aef3ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 213 additions and 146 deletions

View file

@ -1,46 +0,0 @@
---
name: Bug report
about: Create a report to help us improve Oh My Zsh
labels: 'Bug'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**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.

69
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -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...

View file

@ -1,29 +0,0 @@
---
name: Feature request
about: Suggest a feature for Oh My Zsh
labels: 'Feature'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**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! [...]

View file

@ -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!

View file

@ -62,47 +62,47 @@ function acp() {
read -r sess_duration read -r sess_duration
fi fi
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}") 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 # 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 role_arn="$(aws configure get role_arn --profile $profile)"
local sess_name="$(aws configure get role_session_name --profile $profile)" local sess_name="$(aws configure get role_session_name --profile $profile)"
if [[ -n "$role_arn" ]]; then if [[ -n "$role_arn" ]]; then
# Means we need to assume a specified role # Means we need to assume a specified role
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}") aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
# Check whether external_id is configured to use while assuming the role # Check whether external_id is configured to use while assuming the role
local external_id="$(aws configure get external_id --profile $profile)" local external_id="$(aws configure get external_id --profile $profile)"
if [[ -n "$external_id" ]]; then if [[ -n "$external_id" ]]; then
aws_command+=(--external-id "$external_id") 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"
fi fi
# Format output of aws command for easier processing # Get source profile to use to assume role
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) local source_profile="$(aws configure get source_profile --profile $profile)"
if [[ -z "$sess_name" ]]; then
# Run the aws command to obtain credentials sess_name="${source_profile:-profile}"
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 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 fi
# Switch to AWS profile # Switch to AWS profile

View file

@ -5,7 +5,7 @@ copybuffer () {
if which clipcopy &>/dev/null; then if which clipcopy &>/dev/null; then
printf "%s" "$BUFFER" | clipcopy printf "%s" "$BUFFER" | clipcopy
else 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 fi
} }

View file

@ -11,41 +11,51 @@
## Functions ## Functions
source_env() { source_env() {
if [[ -f $ZSH_DOTENV_FILE ]]; then if [[ ! -f "$ZSH_DOTENV_FILE" ]]; then
if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then return
local confirmation dirpath="${PWD:A}" fi
# make sure there is an (dis-)allowed file if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
touch "$ZSH_DOTENV_ALLOWED_LIST" local confirmation dirpath="${PWD:A}"
touch "$ZSH_DOTENV_DISALLOWED_LIST"
# early return if disallowed # make sure there is an (dis-)allowed file
if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then touch "$ZSH_DOTENV_ALLOWED_LIST"
return; touch "$ZSH_DOTENV_DISALLOWED_LIST"
fi
# check if current directory's .env file is allowed or ask for confirmation # early return if disallowed
if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
# print same-line prompt and output newline character if necessary return
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 fi
# test .env syntax # check if current directory's .env file is allowed or ask for confirmation
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 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 # print same-line prompt and output newline character if necessary
source $ZSH_DOTENV_FILE 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 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 autoload -U add-zsh-hook

2
plugins/fnm/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
_fnm

9
plugins/fnm/README.md Normal file
View file

@ -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)
```

View file

@ -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

View file

@ -2,8 +2,8 @@
This plugin supports working with GitHub from the command line. It provides a few things: 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. * 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. * Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem).
* Convenience functions for working with repos and URLs. * Convenience functions for working with repos and URLs.
### Functions ### Functions

View file

@ -36,7 +36,7 @@ __gnu_utils() {
gcmds+=('gfind' 'gxargs' 'glocate') gcmds+=('gfind' 'gxargs' 'glocate')
# Not part of either coreutils or findutils, installed separately. # 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 for gcmd in "${gcmds[@]}"; do
# Do nothing if the command isn't found # Do nothing if the command isn't found

View file

@ -114,6 +114,11 @@ function parse-commit {
fi 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 # Parse commit with hash $1
local hash="$1" subject body warning rhash local hash="$1" subject body warning rhash
subject="$(command git show -s --format=%s $hash)" subject="$(command git show -s --format=%s $hash)"

View file

@ -48,14 +48,17 @@ function update_ohmyzsh() {
return return
fi 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 # 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 # 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. # 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 " trap "
unset -f current_epoch update_last_updated_file update_ohmyzsh ret=\$?
command rm -rf '$ZSH/log/update.lock' unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
return 1 command rm -rf '$ZSH/log/update.lock'
return \$ret
" EXIT INT QUIT " EXIT INT QUIT
# Create or update .zsh-update file if missing or malformed # Create or update .zsh-update file if missing or malformed