From d2dc3bd2da531754778d1e9d7fb082715fc532f1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 12 Jul 2022 18:40:39 +0200 Subject: feat(brew): run `brew shellenv` command at plugin load (#10874) --- plugins/brew/README.md | 12 ++++++++---- plugins/brew/brew.plugin.zsh | 30 +++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index bf952bf01..64e0e1153 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -8,19 +8,23 @@ To use it, add `brew` to the plugins array of your zshrc file: plugins=(... brew) ``` +## Shellenv + +This plugin also executes `brew shellenv` at plugin load to set up many useful variables, such as `HOMEBREW_PREFIX` or `HOMEBREW_REPOSITORY`. + ## Aliases | Alias | Command | Description | -|----------|---------------------------------------|---------------------------------------------------------------------| +| -------- | ------------------------------------- | ------------------------------------------------------------------- | +| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | +| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | | `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | | `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | | `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | -| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | | `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | +| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | | `bubu` | `bubo && bubc` | Do the last two operations above. | | `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). | -| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | -| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | ## Completion diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 070a083d0..4a2322216 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,11 +1,35 @@ +if (( ! $+commands[brew] )); then + if [[ -x /opt/homebrew/bin/brew ]]; then + BREW_LOCATION="/opt/homebrew/bin/brew" + elif [[ -x /usr/local/bin/brew ]]; then + BREW_LOCATION="/usr/local/bin/brew" + elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then + BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew" + elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then + BREW_LOCATION="$HOME/.linuxbrew/bin/brew" + else + return + fi +fi + +if [[ -z "$HOMEBREW_PREFIX" ]]; then + if [[ -z $BREW_LOCATION ]]; then + eval "$(brew shellenv)" + else + eval "$("$BREW_LOCATION" shellenv)" + fi +fi + +unset BREW_LOCATION + +alias bcubc='brew upgrade --cask && brew cleanup' +alias bcubo='brew update && brew outdated --cask' alias brewp='brew pin' alias brewsp='brew list --pinned' -alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' +alias bubo='brew update && brew outdated' alias bubu='bubo && bubc' alias buf='brew upgrade --formula' -alias bcubo='brew update && brew outdated --cask' -alias bcubc='brew upgrade --cask && brew cleanup' function brews() { local formulae="$(brew leaves | xargs brew deps --installed --for-each)" -- cgit v1.2.3-70-g09d2 From 5336e59db1b76b9b5439099cbc5a311796d32ba9 Mon Sep 17 00:00:00 2001 From: Ian Cowan <38896380+iccowan@users.noreply.github.com> Date: Tue, 12 Jul 2022 12:46:42 -0400 Subject: chore(git): fix unintentional latex in documentation (#11018) --- plugins/git/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index b9a0309f3..0700dcc32 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 \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null | +| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null | | gbD | git branch -D | | gbl | git blame -b -w | | gbnm | git branch --no-merged | @@ -42,12 +42,12 @@ plugins=(... git) | gcans! | git commit -v -a -s --no-edit --amend | | gcam | git commit -a -m | | gcas | git commit -a -s | -| gcasm | git commit -a -s -m | +| gcasm | git commit -a -s -m | | gcsm | git commit -s -m | | gcb | git checkout -b | | gcf | git config --list | | gcl | git clone --recurse-submodules | -| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" | +| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" | | gclean | git clean -id | | gpristine | git reset --hard && git clean -dffx | | gcm | git checkout $(git_main_branch) | -- cgit v1.2.3-70-g09d2 From 4506210c38774bc5da1a0495c2a911776cf6f2cb Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jun 2022 12:54:11 +0200 Subject: fix(lib): don't attach to tty in `wl-copy` and `xclip` (#10953) Fixes #10925 --- lib/clipboard.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 4e3ba0a45..272b41598 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -58,10 +58,10 @@ function detect-clipboard() { function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; } elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then - function clipcopy() { wl-copy < "${1:-/dev/stdin}"; } + function clipcopy() { wl-copy < "${1:-/dev/stdin}" &>/dev/null &|; } function clippaste() { wl-paste; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then - function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } + function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}" &>/dev/null &|; } function clippaste() { xclip -out -selection clipboard; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } -- cgit v1.2.3-70-g09d2 From 39573125e4971b34e26f4cb3aaa210a74ea6ca34 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jun 2022 12:49:32 +0200 Subject: feat(lib): wait for input to copy to the clipboard (#10953) --- lib/clipboard.zsh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 272b41598..aab21a28a 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -52,37 +52,37 @@ function detect-clipboard() { emulate -L zsh if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then - function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } function clippaste() { pbpaste; } elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; } elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then - function clipcopy() { wl-copy < "${1:-/dev/stdin}" &>/dev/null &|; } + function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clippaste() { wl-paste; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then - function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}" &>/dev/null &|; } + function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } function clippaste() { xclip -out -selection clipboard; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then - function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } function clippaste() { xsel --clipboard --output; } elif (( ${+commands[lemonade]} )); then - function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; } function clippaste() { lemonade paste; } elif (( ${+commands[doitclient]} )); then - function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | doitclient wclip; } function clippaste() { doitclient wclip -r; } elif (( ${+commands[win32yank]} )); then - function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | win32yank -i; } function clippaste() { win32yank -o; } elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then - function clipcopy() { termux-clipboard-set < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | termux-clipboard-set; } function clippaste() { termux-clipboard-get; } elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } elif [[ $(uname -r) = *icrosoft* ]]; then - function clipcopy() { clip.exe < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } else function _retry_clipboard_detection_or_fail() { -- cgit v1.2.3-70-g09d2 From ef8e63a7fd30e04079e54ea76043c1db76e24ddf Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 12 Jul 2022 18:56:09 +0200 Subject: fix(lib): prefer `xsel` over `xclip` in clipboard.zsh See #10925 --- lib/clipboard.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index aab21a28a..ad83fc4b2 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -10,8 +10,8 @@ # - pbcopy, pbpaste (macOS) # - cygwin (Windows running Cygwin) # - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) -# - xclip (if $DISPLAY is set) # - xsel (if $DISPLAY is set) +# - xclip (if $DISPLAY is set) # - lemonade (for SSH) https://github.com/pocke/lemonade # - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ # - win32yank (Windows) @@ -60,12 +60,12 @@ function detect-clipboard() { elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clippaste() { wl-paste; } - elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then - function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } - function clippaste() { xclip -out -selection clipboard; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } function clippaste() { xsel --clipboard --output; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } + function clippaste() { xclip -out -selection clipboard; } elif (( ${+commands[lemonade]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; } function clippaste() { lemonade paste; } -- cgit v1.2.3-70-g09d2 From 0726c1099fec6599dbf91a260f21d6d45fd8f309 Mon Sep 17 00:00:00 2001 From: Hans Donner Date: Tue, 12 Jul 2022 19:25:27 +0200 Subject: fix(aws): allow non-space characters in profile names (#11040) --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index b8625d7ac..2167f552c 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -147,7 +147,7 @@ function aws_change_access_key() { function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g' + grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g' } function _aws_profiles() { -- cgit v1.2.3-70-g09d2 From 0c7ce363c903e1e3255d4d30255ff4790678ace9 Mon Sep 17 00:00:00 2001 From: hellzbellz <31550512+Hellzbellz123@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:36:43 -0700 Subject: chore(lib): only create `afind` alias if `ack` is installed (#11017) --- lib/misc.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/misc.zsh b/lib/misc.zsh index a5d3af998..1f637083a 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -24,10 +24,10 @@ env_default 'LESS' '-R' ## super user alias alias _='sudo ' -## more intelligent acking for ubuntu users +## more intelligent acking for ubuntu users and no alias for users without ack if (( $+commands[ack-grep] )); then alias afind='ack-grep -il' -else +elif (( $+commands[ack] )); then alias afind='ack -il' fi -- cgit v1.2.3-70-g09d2 From 249c708ed3a4a7a63d16a6e911a46b6fb9623cbd Mon Sep 17 00:00:00 2001 From: Anubhav Sharma Date: Tue, 12 Jul 2022 13:44:32 -0400 Subject: fix(frontcube): fix escape of reset color sequence (#10921) --- themes/frontcube.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/frontcube.zsh-theme b/themes/frontcube.zsh-theme index f9488d0ac..de6348329 100644 --- a/themes/frontcube.zsh-theme +++ b/themes/frontcube.zsh-theme @@ -1,7 +1,7 @@ PROMPT=' %{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%} -%{$fg[green]%}➞ %{$reset_color%' +%{$fg[green]%}➞ %{$reset_color%}' RPROMPT='$(git_prompt_info) $(ruby_prompt_info)' -- cgit v1.2.3-70-g09d2 From bb6c14cdfd0b7d543d0d9c2e5f0c0a9409a82084 Mon Sep 17 00:00:00 2001 From: Brian Wright <4408242+PennRobotics@users.noreply.github.com> Date: Tue, 26 Jul 2022 11:46:10 +0200 Subject: fix(updater): correct spelling of `curl` flag (#11072) --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 009c273fa..cc527e72d 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -65,7 +65,7 @@ function is_update_available() { local remote_head remote_head=$( if (( ${+commands[curl]} )); then - curl --conect-timeout 2 -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null + curl --connect-timeout 2 -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null elif (( ${+commands[wget]} )); then wget -T 2 -O- --header='Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null elif (( ${+commands[fetch]} )); then -- cgit v1.2.3-70-g09d2 From af2daa7ab7dde3674f4861ef684773410b9cccd4 Mon Sep 17 00:00:00 2001 From: Christopher Boyd <6323077+cpboyd@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:06:28 -0400 Subject: feat(flutter): use up-to-date zsh completion (#11062) --- plugins/flutter/_flutter | 37 ------------------------------------- plugins/flutter/flutter.plugin.zsh | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 plugins/flutter/_flutter diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter deleted file mode 100644 index ab6ce4265..000000000 --- a/plugins/flutter/_flutter +++ /dev/null @@ -1,37 +0,0 @@ -#compdef flutter -#autoload - -local -a _1st_arguments -_1st_arguments=( - "analyze":"Analyze the project's Dart code." - "assemble":"Assemble and build flutter resources." - "attach":"Attach to a running application." - "build":"Flutter build commands." - "channel":"List or switch flutter channels." - "clean":"Delete the build/ and .dart_tool/ directories." - "config":"Configure Flutter settings." - "create":"Create a new Flutter project." - "devices":"List all connected devices." - "doctor":"Show information about the installed tooling." - "drive":"Runs Flutter Driver tests for the current project." - "emulators":"List, launch and create emulators." - "format":" Format one or more dart files." - "help":"Display help information for flutter." - "install":"Install a Flutter app on an attached device." - "logs":"Show log output for running Flutter apps." - "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers." - "precache":"Populates the Flutter tool's cache of binary artifacts." - "pub":"Commands for managing Flutter packages." - "run":"Run your Flutter app on an attached device." - "screenshot":"Take a screenshot from a connected device." - "test":"Run Flutter unit tests for the current project." - "upgrade":"Upgrade your copy of Flutter." - "version":"List or switch flutter versions." -) - -_arguments -C '*:: :->subcmds' - -if (( CURRENT == 1 )); then - _describe -t commands "flutter command" _1st_arguments - return -fi diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh index 80b74f64a..44d196cd4 100644 --- a/plugins/flutter/flutter.plugin.zsh +++ b/plugins/flutter/flutter.plugin.zsh @@ -12,3 +12,18 @@ alias flrd="flutter run --debug" alias flrp="flutter run --profile" alias flrr="flutter run --release" alias flupgrd="flutter upgrade" + +# COMPLETION FUNCTION +if (( ! $+commands[flutter] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `flutter`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_flutter" ]]; then + typeset -g -A _comps + autoload -Uz _flutter + _comps[flutter]=_flutter +fi + +flutter zsh-completion >| "$ZSH_CACHE_DIR/completions/_flutter" &| \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 8362ae285a5c227cb20387543483a3597fa31931 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Wed, 27 Jul 2022 16:07:53 +0000 Subject: fix(git-auto-fetch): don't override native `stat` command (#11068) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index efe8cbe66..2e029639c 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -2,7 +2,8 @@ : ${GIT_AUTO_FETCH_INTERVAL:=60} # Necessary for the git-fetch-all function -zmodload zsh/datetime zsh/stat +zmodload zsh/datetime +zmodload -F zsh/stat b:zstat # only zstat command, not stat command function git-fetch-all { ( -- cgit v1.2.3-70-g09d2 From aa75eeea3348b906f2016be0e44335889e0faed1 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Fri, 29 Jul 2022 14:05:34 +0300 Subject: chore(copybuffer): format shortcut and lighten text (#11078) --- plugins/copybuffer/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md index da138bdbd..a53d1c813 100644 --- a/plugins/copybuffer/README.md +++ b/plugins/copybuffer/README.md @@ -1,7 +1,7 @@ # `copybuffer` plugin -This plugin binds the ctrl-o keyboard shortcut to a command that copies the text -that is currently typed in the command line ($BUFFER) to the system clipboard. +This plugin adds the ctrl-o keyboard shortcut to copy the current text +in the command line to the system clipboard. This is useful if you type a command - and before you hit enter to execute it - want to copy it maybe so you can paste it into a script, gist or whatnot. -- cgit v1.2.3-70-g09d2 From 4fcf52c2b1e086596d96b04f9c1ff3d742194857 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 1 Aug 2022 20:54:45 +0200 Subject: fix: don't use `$functions_source` for compatibility with zsh < 5.4 --- plugins/aliases/aliases.plugin.zsh | 23 +++++++----- plugins/shell-proxy/shell-proxy.plugin.zsh | 59 +++++++++++++++++------------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/plugins/aliases/aliases.plugin.zsh b/plugins/aliases/aliases.plugin.zsh index 4e1e0558e..9864de957 100644 --- a/plugins/aliases/aliases.plugin.zsh +++ b/plugins/aliases/aliases.plugin.zsh @@ -1,11 +1,14 @@ -# with lots of 3rd-party amazing aliases installed, just need something to explore it quickly. -# -# - acs: alias cheatsheet -# group alias by command, pass addition argv to grep. -function acs(){ - (( $+commands[python3] )) || { - echo "[error] No python executable detected" - return +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +eval ' + function acs(){ + (( $+commands[python3] )) || { + echo "[error] No python executable detected" + return + } + alias | python3 "'"${0:h}"'/cheatsheet.py" "$@" } - alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@ -} +' diff --git a/plugins/shell-proxy/shell-proxy.plugin.zsh b/plugins/shell-proxy/shell-proxy.plugin.zsh index 9d45b5269..4fdbe9322 100644 --- a/plugins/shell-proxy/shell-proxy.plugin.zsh +++ b/plugins/shell-proxy/shell-proxy.plugin.zsh @@ -1,32 +1,39 @@ #!/usr/bin/bash # shellcheck disable=SC1090,SC2154 -proxy() { - # deprecate $DEFAULT_PROXY, use SHELLPROXY_URL instead - if [[ -n "$DEFAULT_PROXY" && -z "$SHELLPROXY_URL" ]]; then - echo >&2 "proxy: DEFAULT_PROXY is deprecated, use SHELLPROXY_URL instead" - SHELLPROXY_URL="$DEFAULT_PROXY" - unset DEFAULT_PROXY - fi - - # deprecate CONFIG_PROXY, use SHELLPROXY_CONFIG instead - if [[ -n "$CONFIG_PROXY" && -z "$SHELLPROXY_CONFIG" ]]; then - echo >&2 "proxy: CONFIG_PROXY is deprecated, use SHELLPROXY_CONFIG instead" - SHELLPROXY_CONFIG="$CONFIG_PROXY" - unset CONFIG_PROXY - fi - - # the proxy.py script is in the same directory as this function - local proxy="${functions_source[$0]:A:h}/proxy.py" - - # capture the output of the proxy script and bail out if it fails - local output - output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" || - return $? - - # evaluate the output generated by the proxy script - source <(echo "$output") -} +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +eval ' + proxy() { + # deprecate $DEFAULT_PROXY, use SHELLPROXY_URL instead + if [[ -n "$DEFAULT_PROXY" && -z "$SHELLPROXY_URL" ]]; then + echo >&2 "proxy: DEFAULT_PROXY is deprecated, use SHELLPROXY_URL instead" + SHELLPROXY_URL="$DEFAULT_PROXY" + unset DEFAULT_PROXY + fi + + # deprecate CONFIG_PROXY, use SHELLPROXY_CONFIG instead + if [[ -n "$CONFIG_PROXY" && -z "$SHELLPROXY_CONFIG" ]]; then + echo >&2 "proxy: CONFIG_PROXY is deprecated, use SHELLPROXY_CONFIG instead" + SHELLPROXY_CONFIG="$CONFIG_PROXY" + unset CONFIG_PROXY + fi + + # the proxy.py script is in the same directory as this function + local proxy="'"${0:h}"'/proxy.py" + + # capture the output of the proxy script and bail out if it fails + local output + output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" || + return $? + + # evaluate the output generated by the proxy script + source <(echo "$output") + } +' _proxy() { local -r commands=('enable' 'disable' 'status') -- cgit v1.2.3-70-g09d2 From 0346cdf7f63bcddc704cc0551f260d31adb8fc9d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 2 Aug 2022 19:27:54 +0200 Subject: docs: document new aliases policy (#11045) --- .github/PULL_REQUEST_TEMPLATE.md | 1 + CONTRIBUTING.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1abae8913..5c94caeb5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,6 +9,7 @@ - [ ] The code is mine or it's from somewhere with an MIT-compatible license. - [ ] The code is efficient, to the best of my ability, and does not waste computer resources. - [ ] The code is stable and I have tested it myself, to the best of my abilities. +- [ ] If the code introduces new aliases, I provide a valid use case for all plugin users down below. ## Changes: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2bd877892..59cf96012 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,6 +104,27 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa For any extensive change, such as a new plugin, you will have to find testers to +1 your PR. +### New plugin aliases + +We acknowledge that aliases are a core part of Oh My Zsh. There are plugins that have +100 aliases! + +This has become an issue for two opposing reasons: + +- Some users want to have their personal aliases in Oh My Zsh. +- Some users don't want any aliases at all and feel that there are too many. + +Because of this, from now on we're requiring that new aliases follow these conditions: + +1. They will be used by many people, not just a few. +2. The aliases will be used many times and for common tasks. +3. Prefer one generic alias over many specific ones. +4. When justifying the need for an alias, talk about workflows where you'll use it, + preferably in combination with other aliases. +5. If there exists a command with the same name, look for a different alias name. + +This list is not exhaustive! Please remember that your alias will be in the machines of many people, +so it should be justified why they should have it. + ---- ## Use the Search, Luke -- cgit v1.2.3-70-g09d2 From 97134d1eed19b72a9c4bf90a2effa847221608bf Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Tue, 2 Aug 2022 18:28:44 +0100 Subject: fix(cli): make `omz` honour symlinks when changing `.zshrc` (#11082) --- lib/cli.zsh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index b71f6d9ce..db659c11f 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -280,9 +280,10 @@ multi == 1 && length(\$0) > 0 { " local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -294,8 +295,7 @@ multi == 1 && length(\$0) > 0 { # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi @@ -354,9 +354,10 @@ multi == 1 && /^[^#]*\)/ { " local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -368,8 +369,7 @@ multi == 1 && /^[^#]*\)/ { # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi @@ -715,7 +715,8 @@ END { ' local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ || { # Prepend ZSH_THEME= line to .zshrc if it doesn't exist cat < "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -737,8 +738,7 @@ EOF # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi -- cgit v1.2.3-70-g09d2