diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2022-07-03 20:48:55 -0400 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2022-07-03 20:48:55 -0400 |
commit | 6e0a7765188ef970d738108d11eaecc7b79a5f5e (patch) | |
tree | 01712cef5fe2cc74a8bceb2abc2e54ca2c54aff1 | |
parent | 901674e84756d64024cdc70f9590c3557c6d92d6 (diff) | |
parent | 4c82a2eedf0c43d47601ffa8b0303ed1326fab8f (diff) | |
download | zsh-6e0a7765188ef970d738108d11eaecc7b79a5f5e.tar.gz zsh-6e0a7765188ef970d738108d11eaecc7b79a5f5e.tar.bz2 zsh-6e0a7765188ef970d738108d11eaecc7b79a5f5e.zip |
Merge remote-tracking branch 'github/master'
-rw-r--r-- | plugins/cargo/README.md | 3 | ||||
-rw-r--r-- | plugins/cargo/cargo.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/copydir/README.md | 3 | ||||
-rw-r--r-- | plugins/copydir/copydir.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/docker/README.md | 2 | ||||
-rw-r--r-- | plugins/docker/docker.plugin.zsh | 2 | ||||
-rwxr-xr-x | plugins/emacs/emacsclient.sh | 2 | ||||
-rw-r--r-- | plugins/git/README.md | 2 | ||||
-rw-r--r-- | plugins/git/git.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/github/README.md | 1 | ||||
-rw-r--r-- | plugins/github/github.plugin.zsh | 5 | ||||
-rw-r--r-- | plugins/kube-ps1/README.md | 3 | ||||
-rw-r--r-- | plugins/kube-ps1/kube-ps1.plugin.zsh | 39 | ||||
-rw-r--r-- | plugins/npx/README.md | 16 | ||||
-rw-r--r-- | plugins/npx/npx.plugin.zsh | 12 | ||||
-rw-r--r-- | plugins/oc/oc.plugin.zsh | 1 | ||||
-rw-r--r-- | plugins/osx/README.md | 3 | ||||
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 5 | ||||
-rw-r--r-- | plugins/rustup/README.md | 3 | ||||
-rw-r--r-- | plugins/rustup/rustup.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/toolbox/README.md | 6 | ||||
-rw-r--r-- | plugins/toolbox/toolbox.plugin.zsh (renamed from plugins/toolbox/kubectx.plugin.zsh) | 2 | ||||
-rw-r--r-- | tools/check_for_upgrade.sh | 2 |
23 files changed, 50 insertions, 85 deletions
diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md deleted file mode 100644 index 93e69ae7f..000000000 --- a/plugins/cargo/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# cargo - -**Deprecated: use the [`rust`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rust) plugin instead.** diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh deleted file mode 100644 index 692025e8f..000000000 --- a/plugins/cargo/cargo.plugin.zsh +++ /dev/null @@ -1,7 +0,0 @@ -print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'} -print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'} - -(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { - fpath=("$ZSH/plugins/rust" $fpath) - source "$ZSH/plugins/rust/rust.plugin.zsh" -} diff --git a/plugins/copydir/README.md b/plugins/copydir/README.md deleted file mode 100644 index cf24b789f..000000000 --- a/plugins/copydir/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# copydir plugin - -This plugin is deprecated. Use the [`copypath` plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copypath) instead. diff --git a/plugins/copydir/copydir.plugin.zsh b/plugins/copydir/copydir.plugin.zsh deleted file mode 100644 index a2b489ec0..000000000 --- a/plugins/copydir/copydir.plugin.zsh +++ /dev/null @@ -1,7 +0,0 @@ -echo ${(%):-'%F{yellow}The `%Bcopydir%b` plugin is deprecated. Use the `%Bcopypath%b` plugin instead.%f'} -source "$ZSH/plugins/copypath/copypath.plugin.zsh" - -# TODO: 2022-02-22: Remove deprecated copydir function. -function copydir { - copypath -} diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 2b721c770..606690f14 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -57,7 +57,7 @@ the lines below to your zshrc file**, but be aware of the side effects: | dib | `docker image build` | Build an image from a Dockerfile (same as docker build) | | dii | `docker image inspect` | Display detailed information on one or more images | | dils | `docker image ls` | List docker images | -| dip | `docker image push` | Push an image or repository to a remote registry | +| dipu | `docker image push` | Push an image or repository to a remote registry | | dirm | `docker image rm` | Remove one or more images | | dit | `docker image tag` | Add a name and tag to a particular image | | | | **Docker Network** | diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 843c8e241..9c8ad8a28 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -21,7 +21,7 @@ alias dxcit='docker container exec -it' alias dib='docker image build' alias dii='docker image inspect' alias dils='docker image ls' -alias dip='docker image push' +alias dipu='docker image push' alias dirm='docker image rm' alias dit='docker image tag' diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 25efe0d68..96893c932 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -11,7 +11,7 @@ emacsfun() { esac # Check if there are suitable frames - frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null)" + frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )" # Only create another X frame if there isn't one present if [ -z "$frames" -o "$frames" = nil ]; then diff --git a/plugins/git/README.md b/plugins/git/README.md index b9af3488f..b9a0309f3 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -181,6 +181,8 @@ plugins=(... git) | gupv | git pull --rebase -v | | gupa | git pull --rebase --autostash | | gupav | git pull --rebase --autostash -v | +| gupom | git pull --rebase origin $(git_main_branch) | +| gupomi | git pull --rebase=interactive origin $(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]" | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 8f7e623ec..be6adc7ce 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -307,6 +307,8 @@ alias gup='git pull --rebase' alias gupv='git pull --rebase -v' alias gupa='git pull --rebase --autostash' alias gupav='git pull --rebase --autostash -v' +alias gupom='git pull --rebase origin $(git_main_branch)' +alias gupomi='git pull --rebase=interactive origin $(git_main_branch)' alias glum='git pull upstream $(git_main_branch)' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' diff --git a/plugins/github/README.md b/plugins/github/README.md index af2b8a4e7..5d8b62501 100644 --- a/plugins/github/README.md +++ b/plugins/github/README.md @@ -11,7 +11,6 @@ This plugin supports working with GitHub from the command line. It provides a fe * `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub * `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub * `exist_gh` - Takes an existing repo and pushes it to GitHub -* `git.io` - Shortens a URL using [git.io](https://git.io) ## Installation diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh index 8e4b97352..79114ff69 100644 --- a/plugins/github/github.plugin.zsh +++ b/plugins/github/github.plugin.zsh @@ -68,8 +68,9 @@ exist_gh() { # [DIRECTORY] # documentation: https://github.com/blog/985-git-io-github-url-shortener # git.io() { - emulate -L zsh - curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " " + # emulate -L zsh + # curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " " + print -u2 ${(%):-"%F{yellow}%BThe \`git.io\` is deprecated.%b\nView the announcement made by GitHub: https://github.blog/changelog/2022-01-11-git-io-no-longer-accepts-new-urls/%f"} } # End Functions ############################################################# diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md index b08997b0f..1ed3e4438 100644 --- a/plugins/kube-ps1/README.md +++ b/plugins/kube-ps1/README.md @@ -128,6 +128,7 @@ the following environment variables: | `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` | | `KUBE_PS1_PREFIX` | `(` | Prompt opening character | | `KUBE_PS1_SYMBOL_ENABLE` | `true ` | Display the prompt Symbol. If set to `false`, this will also disable `KUBE_PS1_SEPARATOR` | +| `KUBE_PS1_SYMBOL_PADDING` | `false` | Adds a space (padding) after the symbol to prevent clobbering prompt characters | | `KUBE_PS1_SYMBOL_DEFAULT` | `⎈ ` | Default prompt symbol. Unicode `\u2388` | | `KUBE_PS1_SYMBOL_USE_IMG` | `false` | ☸️ , Unicode `\u2638` as the prompt symbol | | `KUBE_PS1_SEPARATOR` | | | Separator between symbol and context name | @@ -151,8 +152,10 @@ The default colors are set with the following environment variables: | Variable | Default | Meaning | | :------- | :-----: | ------- | +| `KUBE_PS1_PREFIX_COLOR` | `null` | Set default color of the prompt prefix | | `KUBE_PS1_SYMBOL_COLOR` | `blue` | Set default color of the Kubernetes symbol | | `KUBE_PS1_CTX_COLOR` | `red` | Set default color of the context | +| `KUBE_PS1_SUFFIX_COLOR` | `null` | Set default color of the prompt suffix | | `KUBE_PS1_NS_COLOR` | `cyan` | Set default color of the namespace | | `KUBE_PS1_BG_COLOR` | `null` | Set default color of the prompt background | diff --git a/plugins/kube-ps1/kube-ps1.plugin.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh index 9e77cbc19..894e0f7f0 100644 --- a/plugins/kube-ps1/kube-ps1.plugin.zsh +++ b/plugins/kube-ps1/kube-ps1.plugin.zsh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash # Kubernetes prompt helper for bash/zsh # Displays current context and namespace -# Copyright 2019 Jon Mosco +# Copyright 2021 Jon Mosco # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +24,8 @@ # Override these values in ~/.zshrc or ~/.bashrc KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}" KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}" -KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388 '} +KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388'} +KUBE_PS1_SYMBOL_PADDING="${KUBE_PS1_SYMBOL_PADDING:-false}" KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-false}" KUBE_PS1_NS_ENABLE="${KUBE_PS1_NS_ENABLE:-true}" KUBE_PS1_CONTEXT_ENABLE="${KUBE_PS1_CONTEXT_ENABLE:-true}" @@ -32,10 +33,12 @@ KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}" KUBE_PS1_SEPARATOR="${KUBE_PS1_SEPARATOR-|}" KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}" KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}" + KUBE_PS1_SYMBOL_COLOR="${KUBE_PS1_SYMBOL_COLOR-blue}" KUBE_PS1_CTX_COLOR="${KUBE_PS1_CTX_COLOR-red}" KUBE_PS1_NS_COLOR="${KUBE_PS1_NS_COLOR-cyan}" KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}" + KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}" KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled" KUBE_PS1_LAST_TIME=0 @@ -149,18 +152,17 @@ _kube_ps1_symbol() { case "${KUBE_PS1_SHELL}" in bash) - if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388 ' != "\\u2388 " ]]; then + if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388' != "\\u2388" ]]; then KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}" - # KUBE_PS1_SYMBOL=$'\u2388 ' - KUBE_PS1_SYMBOL_IMG=$'\u2638 ' + KUBE_PS1_SYMBOL_IMG=$'\u2638\ufe0f' else - KUBE_PS1_SYMBOL=$'\xE2\x8E\x88 ' - KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8 ' + KUBE_PS1_SYMBOL=$'\xE2\x8E\x88' + KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8' fi ;; zsh) KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}" - KUBE_PS1_SYMBOL_IMG="\u2638 ";; + KUBE_PS1_SYMBOL_IMG="\u2638";; *) KUBE_PS1_SYMBOL="k8s" esac @@ -169,7 +171,12 @@ _kube_ps1_symbol() { KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}" fi - echo "${KUBE_PS1_SYMBOL}" + if [[ "${KUBE_PS1_SYMBOL_PADDING}" == true ]]; then + echo "${KUBE_PS1_SYMBOL} " + else + echo "${KUBE_PS1_SYMBOL}" + fi + } _kube_ps1_split() { @@ -339,7 +346,11 @@ kube_ps1() { [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="$(_kube_ps1_color_bg ${KUBE_PS1_BG_COLOR})" # Prefix - [[ -n "${KUBE_PS1_PREFIX}" ]] && KUBE_PS1+="${KUBE_PS1_PREFIX}" + if [[ -z "${KUBE_PS1_PREFIX_COLOR:-}" ]] && [[ -n "${KUBE_PS1_PREFIX}" ]]; then + KUBE_PS1+="${KUBE_PS1_PREFIX}" + else + KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_PREFIX_COLOR)${KUBE_PS1_PREFIX}${KUBE_PS1_RESET_COLOR}" + fi # Symbol KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_SYMBOL_COLOR)$(_kube_ps1_symbol)${KUBE_PS1_RESET_COLOR}" @@ -362,7 +373,11 @@ kube_ps1() { fi # Suffix - [[ -n "${KUBE_PS1_SUFFIX}" ]] && KUBE_PS1+="${KUBE_PS1_SUFFIX}" + if [[ -z "${KUBE_PS1_SUFFIX_COLOR:-}" ]] && [[ -n "${KUBE_PS1_SUFFIX}" ]]; then + KUBE_PS1+="${KUBE_PS1_SUFFIX}" + else + KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_SUFFIX_COLOR)${KUBE_PS1_SUFFIX}${KUBE_PS1_RESET_COLOR}" + fi # Close Background color if defined [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_BG}${_KUBE_PS1_CLOSE_ESC}" diff --git a/plugins/npx/README.md b/plugins/npx/README.md deleted file mode 100644 index 4b2aba8f0..000000000 --- a/plugins/npx/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# npx plugin - -## Deprecation - -Since npm v7, `npx` has been moved to `npm exec`. With the move, [the `--shell-auto-fallback` argument -for `npx` has been removed](https://github.com/npm/cli/blob/v7.0.0/docs/content/cli-commands/npm-exec.md#compatibility-with-older-npx-versions): - -> Shell fallback functionality is removed, as it is not advisable. - -When using npm v7, you'll get this error: - -> npx: the --shell-auto-fallback argument has been removed - -If you get this error, just disable the plugin by removing it from the plugins array in your zshrc file. -This plugin will no longer be maintained and will be removed in the future, when the older `npx` versions -are no longer available. diff --git a/plugins/npx/npx.plugin.zsh b/plugins/npx/npx.plugin.zsh deleted file mode 100644 index c1e2eca98..000000000 --- a/plugins/npx/npx.plugin.zsh +++ /dev/null @@ -1,12 +0,0 @@ -if (( ! $+commands[npx] )); then - return -fi - -if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then - print -u2 ${(%):-"%F{yellow}This \`npx\` version ($(npx --version)) is not supported.%f"} -else - source <(<<< "$npx_fallback_script") -fi - -print -u2 ${(%):-"%F{yellow}The \`npx\` plugin is deprecated and will be removed soon. %BPlease disable it%b.%f"} -unset npx_fallback_script diff --git a/plugins/oc/oc.plugin.zsh b/plugins/oc/oc.plugin.zsh index b968c4bd4..f0e2fc3bc 100644 --- a/plugins/oc/oc.plugin.zsh +++ b/plugins/oc/oc.plugin.zsh @@ -4,4 +4,5 @@ if [ $commands[oc] ]; then source <(oc completion zsh) + compdef _oc oc fi diff --git a/plugins/osx/README.md b/plugins/osx/README.md deleted file mode 100644 index 98d859545..000000000 --- a/plugins/osx/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# osx plugin - -**Deprecated: use the [`macos`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos) plugin instead.** diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh deleted file mode 100644 index 3b0935981..000000000 --- a/plugins/osx/osx.plugin.zsh +++ /dev/null @@ -1,5 +0,0 @@ -print -u2 ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} -print -u2 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} - -(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath) -source "$ZSH/plugins/macos/macos.plugin.zsh" diff --git a/plugins/rustup/README.md b/plugins/rustup/README.md deleted file mode 100644 index c620e72a8..000000000 --- a/plugins/rustup/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# rustup - -**Deprecated: use the [`rust`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rust) plugin instead.** diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh deleted file mode 100644 index ef141cf8f..000000000 --- a/plugins/rustup/rustup.plugin.zsh +++ /dev/null @@ -1,7 +0,0 @@ -print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'} -print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'} - -(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { - fpath=("$ZSH/plugins/rust" $fpath) - source "$ZSH/plugins/rust/rust.plugin.zsh" -} diff --git a/plugins/toolbox/README.md b/plugins/toolbox/README.md index aac2bb3b0..abaca31f4 100644 --- a/plugins/toolbox/README.md +++ b/plugins/toolbox/README.md @@ -17,3 +17,9 @@ You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` ```zsh RPROMPT='$(toolbox_prompt_info)' ``` + +## Aliases + +| Alias | Command | Description | +|-------|----------------------|----------------------------------------| +| tb | `toolbox enter` | Enters the toolbox environment | diff --git a/plugins/toolbox/kubectx.plugin.zsh b/plugins/toolbox/toolbox.plugin.zsh index 8b6bf5ecd..d24d6d396 100644 --- a/plugins/toolbox/kubectx.plugin.zsh +++ b/plugins/toolbox/toolbox.plugin.zsh @@ -1,3 +1,5 @@ function toolbox_prompt_info() { [[ -f /run/.toolboxenv ]] && echo "⬢" } + +alias tb="toolbox enter" diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 149500aa9..009c273fa 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 -m 2 -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null + curl --conect-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 |