diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/aliases/aliases.plugin.zsh | 23 | ||||
-rw-r--r-- | plugins/aws/aws.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/brew/README.md | 12 | ||||
-rw-r--r-- | plugins/brew/brew.plugin.zsh | 30 | ||||
-rw-r--r-- | plugins/copybuffer/README.md | 4 | ||||
-rw-r--r-- | plugins/flutter/_flutter | 37 | ||||
-rw-r--r-- | plugins/flutter/flutter.plugin.zsh | 15 | ||||
-rw-r--r-- | plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 3 | ||||
-rw-r--r-- | plugins/git/README.md | 6 | ||||
-rw-r--r-- | plugins/shell-proxy/shell-proxy.plugin.zsh | 59 |
10 files changed, 104 insertions, 87 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/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() { 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)" 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 <kbd>ctrl-o</kbd> 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. 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 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 { ( 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*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| 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 "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>_ .git)" | | gclean | git clean -id | | gpristine | git reset --hard && git clean -dffx | | gcm | git checkout $(git_main_branch) | 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') |