From 5b4e3ee7f1c48505a3ec56ce38e444b88feda7a4 Mon Sep 17 00:00:00 2001 From: Robert Lankford Date: Mon, 12 Jul 2021 10:16:26 -0500 Subject: 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 -- cgit v1.2.3-70-g09d2 From e4f6f1698d4bf2cebe3fd0e2f5bae9f163780a50 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 12 Jul 2021 17:34:34 +0200 Subject: 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 } -- cgit v1.2.3-70-g09d2 From 23f9348e2c2341df71b1891eb4607f60ddd5a204 Mon Sep 17 00:00:00 2001 From: Sergei Shvetsov Date: Tue, 13 Jul 2021 15:05:33 +0700 Subject: fix(aws): allow for profile switch w/o MFA configured (#9924) --- plugins/aws/aws.plugin.zsh | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 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)" - - 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[@]}") + # 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)" - # 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 + 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[@]}") - # 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}") + # 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 - 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" + # 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}") - # Format output of aws command for easier processing - aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) + 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 - # Run the aws command to obtain credentials - local -a credentials - credentials=(${(ps:\t:)"$(${aws_command[@]})"}) + # Format output of aws command for easier processing + aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) - if [[ -n "$credentials" ]]; then - aws_access_key_id="${credentials[1]}" - aws_secret_access_key="${credentials[2]}" - aws_session_token="${credentials[3]}" - fi + # 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 -- cgit v1.2.3-70-g09d2 From 4eadb9cf758b632b113bb793d5f1e38f4c304392 Mon Sep 17 00:00:00 2001 From: Mahdyar Hasanpour Date: Fri, 16 Jul 2021 14:11:00 +0430 Subject: 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! -- cgit v1.2.3-70-g09d2 From dac3314c76e799cddbbe5cf63870d31861626059 Mon Sep 17 00:00:00 2001 From: "MalaGaM @ ARTiSPRETiS" Date: Fri, 16 Jul 2021 11:48:19 +0200 Subject: 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 -- cgit v1.2.3-70-g09d2 From d9ad99531f74df8b0d6622feeab5e253528b43d0 Mon Sep 17 00:00:00 2001 From: Žiga Šebenik Date: Fri, 23 Jul 2021 12:39:51 +0200 Subject: 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 + -- cgit v1.2.3-70-g09d2 From c8a258698de6a56145211657f05f8b554a8140b7 Mon Sep 17 00:00:00 2001 From: Neil Girdhar Date: Mon, 26 Jul 2021 05:45:02 -0400 Subject: fix(pyenv): fix pyenv PATH settings with a warning (#9935) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes the setting of $PATH for pyenv and its shims, while warning the user about non-interactive shells. Co-authored-by: Marc Cornellà --- plugins/pyenv/pyenv.plugin.zsh | 77 +++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 82ba6ff8c..fedde6342 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -3,44 +3,67 @@ # Load pyenv only if command not already available if command -v pyenv &> /dev/null && [[ "$(uname -r)" != *icrosoft* ]]; then - FOUND_PYENV=1 + FOUND_PYENV=1 else - FOUND_PYENV=0 + FOUND_PYENV=0 fi +# Look for pyenv and try to load it (will only work on interactive shells) if [[ $FOUND_PYENV -ne 1 ]]; then - pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv") - for dir in $pyenvdirs; do - if [[ -d $dir/bin ]]; then - export PATH="$PATH:$dir/bin" - FOUND_PYENV=1 - break - fi - done -fi + pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv") + for dir in $pyenvdirs; do + if [[ -d "$dir/bin" ]]; then + FOUND_PYENV=1 + break + fi + done -if [[ $FOUND_PYENV -ne 1 ]]; then + if [[ $FOUND_PYENV -ne 1 ]]; then if (( $+commands[brew] )) && dir=$(brew --prefix pyenv 2>/dev/null); then - if [[ -d $dir/bin ]]; then - export PATH="$PATH:$dir/bin" - FOUND_PYENV=1 - fi + if [[ -d "$dir/bin" ]]; then + FOUND_PYENV=1 + fi fi + fi + + # If we found pyenv, load it but show a caveat about non-interactive shells + if [[ $FOUND_PYENV -eq 1 ]]; then + cat <&1 | cut -f 2 -d ' ')" - } + # Fall back to system python + function pyenv_prompt_info() { + echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" + } fi unset FOUND_PYENV pyenvdirs dir -- cgit v1.2.3-70-g09d2 From 5377cc37c0f71fe22484303a4c6f387aa339f3f5 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 26 Jul 2021 11:46:15 +0200 Subject: fix(pyenv): fix for ignoring pyenv-win commands The previous fix ignored any pyenv command found in $PATH while on WSL, regardless of whether it was correctly set up or not. This change only ignores the pyenv command if it's proved to come from pyenv-win by looking at its full path. --- plugins/pyenv/pyenv.plugin.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index fedde6342..813f64b42 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,11 +1,13 @@ # This plugin loads pyenv into the current shell and provides prompt info via # the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available. -# Load pyenv only if command not already available -if command -v pyenv &> /dev/null && [[ "$(uname -r)" != *icrosoft* ]]; then - FOUND_PYENV=1 -else +# Look for pyenv in $PATH and verify that it's not a part of pyenv-win in WSL +if ! command -v pyenv &>/dev/null; then + FOUND_PYENV=0 +elif [[ "${commands[pyenv]}" = */pyenv-win/* && "$(uname -r)" = *icrosoft* ]]; then FOUND_PYENV=0 +else + FOUND_PYENV=1 fi # Look for pyenv and try to load it (will only work on interactive shells) -- cgit v1.2.3-70-g09d2 From 9c34c359c4c1ebb1bd0211d40c3bca0c6aa2ca97 Mon Sep 17 00:00:00 2001 From: Aayush Kapoor Date: Fri, 6 Aug 2021 19:21:19 +0530 Subject: chore(ag): fix README (#10001) --- plugins/ag/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ag/README.md b/plugins/ag/README.md index 6acc54067..1983aaa41 100644 --- a/plugins/ag/README.md +++ b/plugins/ag/README.md @@ -5,7 +5,7 @@ This plugin provides completion support for [`ag`](https://github.com/ggreer/the To use it, add ag to the plugins array in your zshrc file. ```zsh -plugins=(... aws) +plugins=(... ag) ``` ## INSTALLATION NOTES -- cgit v1.2.3-70-g09d2 From ab58594173c04f7fe2155a169d8906ef761ba0fc Mon Sep 17 00:00:00 2001 From: Max Eisner <4730112+max-ae@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:31:49 +0200 Subject: feat(git): add `develop` branch name detection (#9881) --- plugins/git/README.md | 35 ++++++++++++++++++----------------- plugins/git/git.plugin.zsh | 19 ++++++++++++++++--- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index e00f4cf92..522257d2d 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -23,7 +23,7 @@ plugins=(... git) | gb | git branch | | gba | git branch -a | | gbd | git branch -d | -| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d | +| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| command xargs -n 1 git branch -d | | gbD | git branch -D | | gbl | git blame -b -w | | gbnm | git branch --no-merged | @@ -49,8 +49,8 @@ plugins=(... git) | gcl | git clone --recurse-submodules | | gclean | git clean -id | | gpristine | git reset --hard && git clean -dffx | -| gcm | git checkout $(git_main_branch) | -| gcd | git checkout develop | +| gcm | git checkout $(git_main_branch) | +| gcd | git checkout $(git_develop_branch) | | gcmsg | git commit -m | | gco | git checkout | | gcor | git checkout --recurse-submodules | @@ -88,7 +88,7 @@ plugins=(... git) | 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 | +| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | | gk | gitk --all --branches | | gke | gitk --all $(git log -g --pretty=%h) | | gl | git pull | @@ -107,10 +107,10 @@ plugins=(... git) | gloga | git log --oneline --decorate --graph --all | | glp | git log --pretty=\ | | gm | git merge | -| gmom | git merge origin/$(git_main_branch) | +| gmom | git merge origin/$(git_main_branch) | | gmt | git mergetool --no-prompt | | gmtvim | git mergetool --no-prompt --tool=vimdiff | -| gmum | git merge upstream/$(git_main_branch) | +| gmum | git merge upstream/$(git_main_branch) | | gma | git merge --abort | | gp | git push | | gpd | git push --dry-run | @@ -125,10 +125,10 @@ plugins=(... git) | grb | git rebase | | grba | git rebase --abort | | grbc | git rebase --continue | -| grbd | git rebase develop | +| grbd | git rebase $(git_develop_branch) | | grbi | git rebase -i | -| grbm | git rebase $(git_main_branch) | -| grbo | git rebase --onto | +| grbm | git rebase $(git_main_branch) | +| grbo | git rebase --onto | | grbs | git rebase --skip | | grev | git revert | | grh | git reset | @@ -176,7 +176,7 @@ plugins=(... git) | gupv | git pull --rebase -v | | gupa | git pull --rebase --autostash | | gupav | git pull --rebase --autostash -v | -| glum | git pull upstream $(git_main_branch) | +| glum | git pull upstream $(git_main_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 -m "--wip-- [skip ci]" | | gam | git am | @@ -214,13 +214,14 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa ### Current -| 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 | +| 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_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 2a7c7290d..3cd558692 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -42,6 +42,19 @@ function git_main_branch() { echo master } +# Check for develop and similarly named branches +function git_develop_branch() { + command git rev-parse --git-dir &>/dev/null || return + local branch + for branch in dev devel development; do + if command git show-ref -q --verify refs/heads/$branch; then + echo $branch + return + fi + done + echo develop +} + # # Aliases # (sorted alphabetically) @@ -60,7 +73,7 @@ alias gapt='git apply --3way' alias gb='git branch' alias gba='git branch -a' alias gbd='git branch -d' -alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs -n 1 git branch -d' alias gbD='git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' @@ -88,7 +101,7 @@ alias gcl='git clone --recurse-submodules' alias gclean='git clean -id' alias gpristine='git reset --hard && git clean -dffx' alias gcm='git checkout $(git_main_branch)' -alias gcd='git checkout develop' +alias gcd='git checkout $(git_develop_branch)' alias gcmsg='git commit -m' alias gco='git checkout' alias gcor='git checkout --recurse-submodules' @@ -227,7 +240,7 @@ alias gra='git remote add' alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' -alias grbd='git rebase develop' +alias grbd='git rebase $(git_develop_branch)' alias grbi='git rebase -i' alias grbm='git rebase $(git_main_branch)' alias grbo='git rebase --onto' -- cgit v1.2.3-70-g09d2 From bca73e18584771fd6db770055dac25b5728764c3 Mon Sep 17 00:00:00 2001 From: Quentin Nerden Date: Tue, 10 Aug 2021 20:25:08 +0200 Subject: feat(plugins): add completion plugin for `invoke` (#7311) Co-authored-by: Quentin Nerden --- plugins/invoke/README.md | 10 ++++++++++ plugins/invoke/invoke.plugin.zsh | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 plugins/invoke/README.md create mode 100644 plugins/invoke/invoke.plugin.zsh diff --git a/plugins/invoke/README.md b/plugins/invoke/README.md new file mode 100644 index 000000000..3f4b88078 --- /dev/null +++ b/plugins/invoke/README.md @@ -0,0 +1,10 @@ +# Invoke plugin + +This plugin adds completion for [invoke](https://github.com/pyinvoke/invoke). + +To use it, add `invoke` to the plugins array in your `~/.zshrc` file: + +```zsh +plugins=(... invoke) +``` + diff --git a/plugins/invoke/invoke.plugin.zsh b/plugins/invoke/invoke.plugin.zsh new file mode 100644 index 000000000..8c807de02 --- /dev/null +++ b/plugins/invoke/invoke.plugin.zsh @@ -0,0 +1,5 @@ +# Autocompletion for invoke. +# +if [ $commands[invoke] ]; then + source <(invoke --print-completion-script=zsh) +fi -- cgit v1.2.3-70-g09d2 From b79fba7b0d38aa61afaeeaaa7fab6992dbfb6db3 Mon Sep 17 00:00:00 2001 From: Gregor Trefs Date: Tue, 10 Aug 2021 21:02:06 +0200 Subject: feat(plugins): `octozen` shows an Octocat zen quote on startup (#5959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/octozen/README.md | 12 ++++++++++++ plugins/octozen/octozen.plugin.zsh | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/octozen/README.md create mode 100644 plugins/octozen/octozen.plugin.zsh diff --git a/plugins/octozen/README.md b/plugins/octozen/README.md new file mode 100644 index 000000000..2051248ca --- /dev/null +++ b/plugins/octozen/README.md @@ -0,0 +1,12 @@ +# Octozen plugin + +Displays a zen quote from GitHub's Octocat on start up. + +To use it, add `octozen` to the plugins array in your zshrc file: + +```zsh +plugins=(... octozen) +``` + +It defines a `display_octozen` function that fetches a GitHub Octocat zen quote. +NOTE: Internet connection is required (will time out if not fetched in 2 seconds). diff --git a/plugins/octozen/octozen.plugin.zsh b/plugins/octozen/octozen.plugin.zsh new file mode 100644 index 000000000..71ee550a5 --- /dev/null +++ b/plugins/octozen/octozen.plugin.zsh @@ -0,0 +1,11 @@ +# octozen plugin + +# Displays a zen quote from octocat +function display_octozen() { + curl -m 2 -fsL "https://api.github.com/octocat" + add-zsh-hook -d precmd display_octozen +} + +# Display the octocat on the first precmd, after the whole starting process has finished +autoload -Uz add-zsh-hook +add-zsh-hook precmd display_octozen -- cgit v1.2.3-70-g09d2 From c24928815179e1a8e1e3a0a4ab130e22ba2e0f1a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 10 Aug 2021 21:05:00 +0200 Subject: feat(lib): add `mkcd` as equivalent to `takedir` (#9749) Fixes #9749 --- lib/functions.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 9cc735196..24b7254fb 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() { omz update } -function takedir() { - mkdir -p $@ && cd ${@:$#} -} - function open_command() { local open_cmd @@ -37,6 +33,13 @@ function open_command() { ${=open_cmd} "$@" &>/dev/null } +# take functions + +# mkcd is equivalent to takedir +function mkcd takedir() { + mkdir -p $@ && cd ${@:$#} +} + function takeurl() { data=$(mktemp) curl -L $1 > $data -- cgit v1.2.3-70-g09d2 From 7eeb1e193d4a55ab706931fb80ef556a939be8fd Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 10 Aug 2021 21:09:21 +0200 Subject: refactor(lib): refactor take functions --- lib/functions.zsh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 24b7254fb..73b491a59 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -41,26 +41,27 @@ function mkcd takedir() { } function takeurl() { - data=$(mktemp) - curl -L $1 > $data - tar xf $data - thedir=$(tar tf $data | head -1) - rm $data - cd $thedir + local data thedir + data="$(mktemp)" + curl -L "$1" > "$data" + tar xf "$data" + thedir="$(tar tf "$data" | head -1)" + rm "$data" + cd "$thedir" } function takegit() { - git clone $1 - cd $(basename ${1%%.git}) + git clone "$1" + cd "$(basename ${1%%.git})" } function take() { if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then - takeurl $1 + takeurl "$1" elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then - takegit $1 + takegit "$1" else - takedir $1 + takedir "$@" fi } -- cgit v1.2.3-70-g09d2 From 6e4c9df4a433849a2c636980dc317db0fba3a0f5 Mon Sep 17 00:00:00 2001 From: James Eapen Date: Fri, 13 Aug 2021 06:33:30 -0400 Subject: feat(cli): add `plugin load` subcommand (#9872) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9672 Co-authored-by: Marc Cornellà --- lib/cli.zsh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 5 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 38e2f72f8..7e3e37be8 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -37,7 +37,7 @@ function _omz { changelog) local -a refs refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") _describe 'command' refs ;; - plugin) subcmds=('info:Get plugin information' 'list:List plugins') + plugin) subcmds=('info:Get plugin information' 'list:List plugins' 'load:Load plugin(s)') _describe 'command' subcmds ;; pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') _describe 'command' subcmds ;; @@ -46,10 +46,26 @@ function _omz { esac elif (( CURRENT == 4 )); then case "$words[2]::$words[3]" in - plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \ - "$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;; - theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \ - "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;; + plugin::(info|load)) + local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + _describe 'plugin' plugins ;; + theme::use) + local -aU themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) + _describe 'theme' themes ;; + esac + elif (( CURRENT > 4 )); then + case "$words[2]::$words[3]" in + plugin::load) + local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + + # Remove plugins already passed as arguments + # NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which + # has a space after them. This is to avoid removing plugins partially passed, which makes + # the completion not add a space after the completed plugin. + local -a args=(${words[4,$(( CURRENT - 1))]}) + plugins=(${plugins:|args}) + + _describe 'plugin' plugins ;; esac fi @@ -147,6 +163,7 @@ Available commands: info Get information of a plugin list List all available Oh My Zsh plugins + load Load plugin(s) EOF return 1 @@ -205,6 +222,56 @@ function _omz::plugin::list { fi } +function _omz::plugin::load { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz plugin load [...]" + return 1 + fi + + local plugins=("$@") + local plugin base has_completion=0 + + for plugin in $plugins; do + if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then + base="$ZSH_CUSTOM/plugins/$plugin" + elif [[ -d "$ZSH/plugins/$plugin" ]]; then + base="$ZSH/plugins/$plugin" + else + _omz::log warn "plugin '$plugin' not found" + continue + fi + + # Check if its a valid plugin + if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then + _omz::log warn "'$plugin' is not a valid plugin" + continue + # It it is a valid plugin, add its directory to $fpath unless it is already there + elif (( ! ${fpath[(Ie)$base]} )); then + fpath=("$base" $fpath) + fi + + # Check if it has completion to reload compinit + if [[ -f "$base/_$plugin" ]]; then + has_completion=1 + fi + + # Load the plugin + if [[ -f "$base/$plugin.plugin.zsh" ]]; then + source "$base/$plugin.plugin.zsh" + fi + done + + # If we have completion, we need to reload the completion + # We pass -D to avoid generating a new dump file, which would overwrite our + # current one for the next session (and we don't want that because we're not + # actually enabling the plugins for the next session). + # Note that we still have to pass -d "$_comp_dumpfile", so that compinit + # doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump). + if (( has_completion )); then + compinit -D -d "$_comp_dumpfile" + fi +} + function _omz::pr { (( $# > 0 && $+functions[_omz::pr::$1] )) || { cat < Date: Fri, 13 Aug 2021 12:38:22 +0200 Subject: refactor(fedora)!: remove deprecated `fedora` plugin BREAKING CHANGE: the `fedora` plugin has been removed. Use the `dnf` plugin instead. --- plugins/fedora/README.md | 1 - plugins/fedora/fedora.plugin.zsh | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 plugins/fedora/README.md delete mode 100644 plugins/fedora/fedora.plugin.zsh diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md deleted file mode 100644 index 85d8d7dea..000000000 --- a/plugins/fedora/README.md +++ /dev/null @@ -1 +0,0 @@ -The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead. diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh deleted file mode 100644 index 226506c05..000000000 --- a/plugins/fedora/fedora.plugin.zsh +++ /dev/null @@ -1,3 +0,0 @@ -print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f" - -source "$ZSH/plugins/dnf/dnf.plugin.zsh" -- cgit v1.2.3-70-g09d2 From e1f0d826f1f0d362eb377ef4a8124062ec63c3e9 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 13 Aug 2021 12:40:20 +0200 Subject: refactor(go)!: remove deprecated `go` plugin BREAKING CHANGE: the `go` plugin has been removed. Use the `golang` plugin instead. --- plugins/go/README.md | 1 - plugins/go/go.plugin.zsh | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 plugins/go/README.md delete mode 100644 plugins/go/go.plugin.zsh diff --git a/plugins/go/README.md b/plugins/go/README.md deleted file mode 100644 index bf43b9feb..000000000 --- a/plugins/go/README.md +++ /dev/null @@ -1 +0,0 @@ -The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead. diff --git a/plugins/go/go.plugin.zsh b/plugins/go/go.plugin.zsh deleted file mode 100644 index da7c87cfd..000000000 --- a/plugins/go/go.plugin.zsh +++ /dev/null @@ -1,3 +0,0 @@ -print -P "%F{yellow}The 'go' plugin is deprecated. Use the '%Ugolang%u' plugin instead.%f" - -source "$ZSH/plugins/golang/golang.plugin.zsh" -- cgit v1.2.3-70-g09d2 From af6c7f3d6782cf0a34e4e68f661df526d35795be Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 13 Aug 2021 12:42:56 +0200 Subject: refactor(cloudapp)!: remove deprecated `cloudapp` plugin BREAKING CHANGE: the `cloudapp` plugin has been removed due to removed API. --- plugins/cloudapp/README.md | 26 -------------------------- plugins/cloudapp/cloudapp.plugin.zsh | 4 ---- 2 files changed, 30 deletions(-) delete mode 100644 plugins/cloudapp/README.md delete mode 100644 plugins/cloudapp/cloudapp.plugin.zsh diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md deleted file mode 100644 index ef304edc2..000000000 --- a/plugins/cloudapp/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# CloudApp plugin - -## The CloudApp API is deprecated, so the plugin will be removed shortly - -[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line. - -To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file: - -```zsh -plugins=(... cloudapp) -``` - -## Requirements - -1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation) - -2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below: - ``` - email - password - ``` - -## Usage - -- `cloudapp `: uploads `` to your CloudApp account, and if you're using - macOS, copies the URL to your clipboard. diff --git a/plugins/cloudapp/cloudapp.plugin.zsh b/plugins/cloudapp/cloudapp.plugin.zsh deleted file mode 100644 index a4d92a080..000000000 --- a/plugins/cloudapp/cloudapp.plugin.zsh +++ /dev/null @@ -1,4 +0,0 @@ -print -Pn "%F{yellow}" -print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will" -print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list." -print -Pn "%f" -- cgit v1.2.3-70-g09d2 From 6dc937ff685fcbc43056dbd7fb05ba01c56dfd1a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 4 Aug 2021 15:49:11 +0200 Subject: feat(extract): add suport for .cab files via `cabextract` --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index f2e6ad1d1..1dd8e19c0 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -21,6 +21,7 @@ plugins=(... extract) | `apk` | Android app file | | `aar` | Android library file | | `bz2` | Bzip2 file | +| `cab` | Microsoft cabinet archive | | `deb` | Debian package | | `ear` | Enterprise Application aRchive | | `gz` | Gzip file | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 267c4d4e1..31a7facbe 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index e390e2dcc..601272cac 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -55,7 +55,7 @@ extract() { (*.lz4) lz4 -d "$1" ;; (*.lzma) unlzma "$1" ;; (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; (*.rar) unrar x -ad "$1" ;; (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; @@ -69,6 +69,7 @@ extract() { cd .. ;; (*.zst) unzstd "$1" ;; + (*.cab) cabextract -d "$extract_dir" "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 -- cgit v1.2.3-70-g09d2 From 59a9b453d348baad4ff7b7cb2e1f205d615200e6 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuna Date: Mon, 24 Jun 2019 00:54:28 +0300 Subject: fix(extract): support unpacking deb file from different directory --- plugins/extract/extract.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 601272cac..e63b9494f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -60,13 +60,13 @@ extract() { (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; (*.deb) - mkdir -p "$extract_dir/control" - mkdir -p "$extract_dir/data" - cd "$extract_dir"; ar vx "../${1}" > /dev/null - cd control; tar xzvf ../control.tar.gz - cd ../data; extract ../data.tar.* - cd ..; rm *.tar.* debian-binary - cd .. + local pwd="$PWD" file="${1:A}" + mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$file" > /dev/null + builtin cd -q control; extract ../control.tar.* + builtin cd -q ../data; extract ../data.tar.* + builtin cd -q ..; command rm *.tar.* debian-binary + builtin cd -q "$pwd" ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; -- cgit v1.2.3-70-g09d2 From 0b506fea0c9aeb450db6fdaba572041fd900c05b Mon Sep 17 00:00:00 2001 From: Xeonacid Date: Wed, 9 Jun 2021 19:29:04 +0800 Subject: feat(extract): add cpio support --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 1dd8e19c0..44f0b05a1 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -22,6 +22,7 @@ plugins=(... extract) | `aar` | Android library file | | `bz2` | Bzip2 file | | `cab` | Microsoft cabinet archive | +| `cpio` | Cpio archive | | `deb` | Debian package | | `ear` | Enterprise Application aRchive | | `gz` | Gzip file | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 31a7facbe..27b099c9e 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index e63b9494f..ac181fa78 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -70,6 +70,7 @@ extract() { ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; + (*.cpio) cpio -idmvF "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 -- cgit v1.2.3-70-g09d2 From a2f1ef69b570b43bbdd0fa29bddb860293b7278b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 14 Aug 2021 21:57:56 +0200 Subject: fix(extract): correctly extract rpm files on other directories --- plugins/extract/extract.plugin.zsh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index ac181fa78..12a1ec948 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -20,6 +20,7 @@ extract() { shift fi + local pwd="$PWD" while (( $# > 0 )); do if [[ ! -f "$1" ]]; then echo "extract: '$1' is not a valid file" >&2 @@ -29,6 +30,7 @@ extract() { success=0 extract_dir="${1:t:r}" + local full_path="${1:A}" case "${1:l}" in (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; @@ -57,17 +59,16 @@ extract() { (*.z) uncompress "$1" ;; (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; (*.rar) unrar x -ad "$1" ;; - (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; + (*.rpm) + command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ + && rpm2cpio "$full_path" | cpio --quiet -id ;; (*.7z) 7za x "$1" ;; (*.deb) - local pwd="$PWD" file="${1:A}" - mkdir -p "$extract_dir/control" "$extract_dir/data" - builtin cd -q "$extract_dir"; ar vx "$file" > /dev/null + command mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null builtin cd -q control; extract ../control.tar.* builtin cd -q ../data; extract ../data.tar.* - builtin cd -q ..; command rm *.tar.* debian-binary - builtin cd -q "$pwd" - ;; + builtin cd -q ..; command rm *.tar.* debian-binary ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; (*.cpio) cpio -idmvF "$1" ;; @@ -77,8 +78,11 @@ extract() { ;; esac - (( success = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + (( success = success > 0 ? success : $? )) + (( success == 0 && remove_archive == 0 )) && rm "$full_path" shift + + # Go back to original working directory in case we ran cd previously + builtin cd -q "$pwd" done } -- cgit v1.2.3-70-g09d2 From 10a00085d027a969c7ef27e52085ca1fa7f5668c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 14 Aug 2021 22:05:48 +0200 Subject: fix(extract): don't push entries to dirstack when extracting rpm and deb files --- plugins/extract/extract.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 12a1ec948..a257f6bc3 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,6 +1,8 @@ alias x=extract extract() { + setopt localoptions noautopushd + local remove_archive local success local extract_dir -- cgit v1.2.3-70-g09d2 From 0b32e4b25fa7f3215964281a8af4e3ff2bf4cd68 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 14 Aug 2021 22:03:41 +0200 Subject: style(extract): adopt main code style guide and refactor variables --- plugins/extract/extract.plugin.zsh | 153 ++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 79 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index a257f6bc3..1112dd52f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,90 +1,85 @@ alias x=extract extract() { - setopt localoptions noautopushd + setopt localoptions noautopushd - local remove_archive - local success - local extract_dir + if (( $# == 0 )); then + cat >&2 <<'EOF' +Usage: extract [-option] [file ...] - if (( $# == 0 )); then - cat <<-'EOF' >&2 - Usage: extract [-option] [file ...] +Options: + -r, --remove Remove archive after unpacking. +EOF + fi - Options: - -r, --remove Remove archive after unpacking. - EOF - fi + local remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi - remove_archive=1 - if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 - shift - fi + local pwd="$PWD" + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi - local pwd="$PWD" - while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then - echo "extract: '$1' is not a valid file" >&2 - shift - continue - fi + local success=0 + local extract_dir="${1:t:r}" + local file="$1" full_path="${1:A}" + case "${file:l}" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$file" \ + || xzcat "$file" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$file" \ + || lzcat "$file" | tar xvf - ;; + (*.tar.zst|*.tzst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$file" \ + || zstdcat "$file" | tar xvf - ;; + (*.tar) tar xvf "$file" ;; + (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;; + (*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;; + (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;; + (*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;; + (*.bz2) bunzip2 "$file" ;; + (*.xz) unxz "$file" ;; + (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;; + (*.lz4) lz4 -d "$file" ;; + (*.lzma) unlzma "$file" ;; + (*.z) uncompress "$file" ;; + (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;; + (*.rar) unrar x -ad "$file" ;; + (*.rpm) + command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ + && rpm2cpio "$full_path" | cpio --quiet -id ;; + (*.7z) 7za x "$file" ;; + (*.deb) + command mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null + builtin cd -q control; extract ../control.tar.* + builtin cd -q ../data; extract ../data.tar.* + builtin cd -q ..; command rm *.tar.* debian-binary ;; + (*.zst) unzstd "$file" ;; + (*.cab) cabextract -d "$extract_dir" "$file" ;; + (*.cpio) cpio -idmvF "$file" ;; + (*) + echo "extract: '$file' cannot be extracted" >&2 + success=1 ;; + esac - success=0 - extract_dir="${1:t:r}" - local full_path="${1:A}" - case "${1:l}" in - (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) - tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; - (*.tar.zma|*.tlz) - tar --lzma --help &> /dev/null \ - && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar.zst|*.tzst) - tar --zstd --help &> /dev/null \ - && tar --zstd -xvf "$1" \ - || zstdcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; - (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;; - (*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;; - (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;; - (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;; - (*.bz2) bunzip2 "$1" ;; - (*.xz) unxz "$1" ;; - (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;; - (*.lz4) lz4 -d "$1" ;; - (*.lzma) unlzma "$1" ;; - (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; - (*.rar) unrar x -ad "$1" ;; - (*.rpm) - command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ - && rpm2cpio "$full_path" | cpio --quiet -id ;; - (*.7z) 7za x "$1" ;; - (*.deb) - command mkdir -p "$extract_dir/control" "$extract_dir/data" - builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null - builtin cd -q control; extract ../control.tar.* - builtin cd -q ../data; extract ../data.tar.* - builtin cd -q ..; command rm *.tar.* debian-binary ;; - (*.zst) unzstd "$1" ;; - (*.cab) cabextract -d "$extract_dir" "$1" ;; - (*.cpio) cpio -idmvF "$1" ;; - (*) - echo "extract: '$1' cannot be extracted" >&2 - success=1 - ;; - esac + (( success = success > 0 ? success : $? )) + (( success == 0 && remove_archive == 0 )) && rm "$full_path" + shift - (( success = success > 0 ? success : $? )) - (( success == 0 && remove_archive == 0 )) && rm "$full_path" - shift - - # Go back to original working directory in case we ran cd previously - builtin cd -q "$pwd" - done + # Go back to original working directory in case we ran cd previously + builtin cd -q "$pwd" + done } -- cgit v1.2.3-70-g09d2 From 7c5ab01a5f7b07481182108117db070b8cabb2e6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 14 Aug 2021 22:41:48 +0200 Subject: fix(changelog): also display commits from merged branches --- tools/changelog.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 56ea42cb1..6913ae49a 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -391,9 +391,7 @@ function main { # Get commit list from $until commit until $since commit, or until root # commit if $since is unset, in short hash form. - # --first-parent is used when dealing with merges: it only prints the - # merge commit, not the commits of the merged branch. - command git rev-list --first-parent --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do + command git rev-list --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do # Truncate list on versions with a lot of commits if [[ -z "$since" ]] && (( ++read_commits > 35 )); then truncate=1 -- cgit v1.2.3-70-g09d2 From 11e22ed0b5c1aebd6e990ea7a885bdf03ab6555a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 14 Aug 2021 22:54:07 +0200 Subject: docs(dirhistory): document keyboard shortcut conflict with Windows Terminal Related: https://github.com/ohmyzsh/ohmyzsh/issues/8505#issuecomment-886241162 --- plugins/dirhistory/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md index 223650727..602fc8284 100644 --- a/plugins/dirhistory/README.md +++ b/plugins/dirhistory/README.md @@ -17,6 +17,9 @@ plugins=(... dirhistory) | alt + up | Move into the parent directory | | alt + down | Move into the first child directory by alphabetical order | +NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example). +If these don't work check your terminal settings and change them to a different keyboard shortcut. + ## Usage This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT. -- cgit v1.2.3-70-g09d2