From fd9781b4c7036a3ef0a62744b9ecae327f9f2f24 Mon Sep 17 00:00:00 2001 From: MDHD Date: Mon, 6 Jul 2020 10:13:49 -0500 Subject: sudo: make the behavior more in line with expectations (#9047) --- plugins/sudo/sudo.plugin.zsh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index f405b025f..51579377d 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -13,15 +13,28 @@ # ------------------------------------------------------------------------------ sudo-command-line() { - [[ -z $BUFFER ]] && zle up-history - if [[ $BUFFER == sudo\ * ]]; then - LBUFFER="${LBUFFER#sudo }" - elif [[ $BUFFER == $EDITOR\ * ]]; then - LBUFFER="${LBUFFER#$EDITOR }" - LBUFFER="sudoedit $LBUFFER" + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" + if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then + if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then + RBUFFER=" ${BUFFER#$EDITOR }" + LBUFFER="sudoedit" + else + LBUFFER="sudoedit ${LBUFFER#$EDITOR }" + fi elif [[ $BUFFER == sudoedit\ * ]]; then - LBUFFER="${LBUFFER#sudoedit }" - LBUFFER="$EDITOR $LBUFFER" + if [[ ${#LBUFFER} -le 8 ]]; then + RBUFFER=" ${BUFFER#sudoedit }" + LBUFFER="$EDITOR" + else + LBUFFER="$EDITOR ${LBUFFER#sudoedit }" + fi + elif [[ $BUFFER == sudo\ * ]]; then + if [[ ${#LBUFFER} -le 4 ]]; then + RBUFFER="${BUFFER#sudo }" + LBUFFER="" + else + LBUFFER="${LBUFFER#sudo }" + fi else LBUFFER="sudo $LBUFFER" fi -- cgit v1.2.3-70-g09d2 From d79941b78997f7c11e247c08678fd57827db3b42 Mon Sep 17 00:00:00 2001 From: Lutz Horn Date: Thu, 9 Jul 2020 10:43:59 +0200 Subject: aws: allow @ in AWS profiles (#9099) Fixes #9060 by matching a `@` in the AWS profile name. --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 4b5446407..d00c2e56c 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -41,7 +41,7 @@ function aws_change_access_key() { function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/' } function _aws_profiles() { -- cgit v1.2.3-70-g09d2 From 1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 9 Jul 2020 11:16:16 +0200 Subject: git: use `master` if it exists, otherwise use `main` See https://github.com/ohmyzsh/ohmyzsh/pull/9049#issuecomment-654537347 Co-authored-by: Yufan You --- plugins/git/README.md | 6 +++--- plugins/git/git.plugin.zsh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/git/README.md b/plugins/git/README.md index b7f216813..e809e1bcd 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -183,8 +183,8 @@ plugins=(... git) Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means -that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the -function `git_main_branch`. +that any aliases and functions that previously used `master`, will use `main` if `master` doesn't exist. We do this via +the function `git_main_branch`. ### Deprecated aliases @@ -214,7 +214,7 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa | 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_main_branch | Returns the name of the main branch: `master` if it exists, `main` otherwise | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 5a9ccff5c..6cae3dac2 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -27,10 +27,10 @@ function work_in_progress() { # Check if main exists and use instead of master function git_main_branch() { - if [[ -n "$(git branch --list main)" ]]; then - echo main - else + if [[ -n "$(git branch --list master)" ]]; then echo master + else + echo main fi } -- cgit v1.2.3-70-g09d2 From 327ac697c7542f03c69edca1515656a653f23656 Mon Sep 17 00:00:00 2001 From: Veit Lehmann Date: Thu, 9 Jul 2020 11:23:49 +0200 Subject: mix-fast: add decriptions to mix-fast completions (#8561) * feat(mix-fast): include desctiptions (#8561) * feat(mix-fast): improve _mix_generate (no tail, better matching) --- plugins/mix-fast/mix-fast.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mix-fast/mix-fast.plugin.zsh b/plugins/mix-fast/mix-fast.plugin.zsh index e27e30d64..564c50561 100644 --- a/plugins/mix-fast/mix-fast.plugin.zsh +++ b/plugins/mix-fast/mix-fast.plugin.zsh @@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () { } _mix_generate () { - mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks + mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks } _mix () { @@ -21,7 +21,8 @@ _mix () { echo "\nGenerating .mix_tasks..." > /dev/stderr _mix_generate fi - compadd `cat .mix_tasks` + local tasks=(${(f)"$(cat .mix_tasks)"}) + _describe 'tasks' tasks fi } -- cgit v1.2.3-70-g09d2 From 7deaff71a2be08145d83f0177edbf2dfb3e91262 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Thu, 9 Jul 2020 15:29:26 +0200 Subject: yarn: add alias for upgrade-interactive to the latest version (#8764) --- plugins/yarn/README.md | 65 ++++++++++++++++++++++---------------------- plugins/yarn/yarn.plugin.zsh | 1 + 2 files changed, 34 insertions(+), 32 deletions(-) (limited to 'plugins') diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index 05f18a499..fd748b742 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -11,35 +11,36 @@ plugins=(... yarn) ## Aliases -| Alias | Command | Description | -|-------|-------------------------------------------|-------------------------------------------------------------| -| y | `yarn` | The Yarn command | -| ya | `yarn add` | Install a package in dependencies (`package.json`) | -| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) | -| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | -| yb | `yarn build` | Run the build script defined in `package.json` | -| ycc | `yarn cache clean` | Clean yarn's global cache of packages | -| yd | `yarn dev` | Run the dev script defined in `package.json` | -| yga | `yarn global add` | Install packages globally on your operating system | -| ygls | `yarn global list` | Lists global installed packages | -| ygrm | `yarn global remove` | Remove global installed packages from your OS | -| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version | -| yh | `yarn help` | Show help for a yarn command | -| yi | `yarn init` | Interactively creates or updates a package.json file | -| yin | `yarn install` | Install dependencies defined in `package.json` | -| yln | `yarn lint` | Run the lint script defined in `package.json` | -| yls | `yarn list` | List installed packages | -| yout | `yarn outdated` | Check for outdated package dependencies | -| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | -| yrm | `yarn remove` | Remove installed packages | -| yrun | `yarn run` | Run a defined package script | -| ys | `yarn serve` | Start the dev server | -| yst | `yarn start` | Run the start script defined in `package.json` | -| yt | `yarn test` | Run the test script defined in `package.json` | -| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage | -| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | -| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | -| yup | `yarn upgrade` | Upgrade packages to their latest version | -| yv | `yarn version` | Update the version of your package | -| yw | `yarn workspace` | Run a command within a single workspace. | -| yws | `yarn workspaces` | Run a command within all defined workspaces. | +| Alias | Command | Description | +| ----- | ----------------------------------------- | ----------------------------------------------------------------------------- | +| y | `yarn` | The Yarn command | +| ya | `yarn add` | Install a package in dependencies (`package.json`) | +| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) | +| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | +| yb | `yarn build` | Run the build script defined in `package.json` | +| ycc | `yarn cache clean` | Clean yarn's global cache of packages | +| yd | `yarn dev` | Run the dev script defined in `package.json` | +| yga | `yarn global add` | Install packages globally on your operating system | +| ygls | `yarn global list` | Lists global installed packages | +| ygrm | `yarn global remove` | Remove global installed packages from your OS | +| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version | +| yh | `yarn help` | Show help for a yarn command | +| yi | `yarn init` | Interactively creates or updates a package.json file | +| yin | `yarn install` | Install dependencies defined in `package.json` | +| yln | `yarn lint` | Run the lint script defined in `package.json` | +| yls | `yarn list` | List installed packages | +| yout | `yarn outdated` | Check for outdated package dependencies | +| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | +| yrm | `yarn remove` | Remove installed packages | +| yrun | `yarn run` | Run a defined package script | +| ys | `yarn serve` | Start the dev server | +| yst | `yarn start` | Run the start script defined in `package.json` | +| yt | `yarn test` | Run the test script defined in `package.json` | +| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage | +| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | +| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | +| yuil | `yarn upgrade-interactive --latest` | Prompt for which outdated packages to upgrade to the latest available version | +| yup | `yarn upgrade` | Upgrade packages to their latest version | +| yv | `yarn version` | Update the version of your package | +| yw | `yarn workspace` | Run a command within a single workspace. | +| yws | `yarn workspaces` | Run a command within all defined workspaces. | diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index 9cfcb7539..4a5192c61 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -24,6 +24,7 @@ alias yt="yarn test" alias ytc="yarn test --coverage" alias yuc="yarn global upgrade && yarn cache clean" alias yui="yarn upgrade-interactive" +alias yuil="yarn upgrade-interactive --latest" alias yup="yarn upgrade" alias yv="yarn version" alias yw="yarn workspace" -- cgit v1.2.3-70-g09d2 From 9cdc2764967f9255fa343e77217d62d2703d5549 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Sat, 11 Jul 2020 17:34:24 +0200 Subject: dotenv: add never option to confirmation prompt (#9102) --- plugins/dotenv/README.md | 24 +++++++++++++++--------- plugins/dotenv/dotenv.plugin.zsh | 12 ++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index f66124731..ab9d329f6 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -53,24 +53,30 @@ Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmat You can also choose the `Always` option when prompted to always allow sourcing the .env file in that directory. See the next section for more details. -### ZSH_DOTENV_ALLOWED_LIST +### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST The default behavior of the plugin is to always ask whether to source a dotenv file. There's -a **Y**es, **N**o, and **A**lways option. If you choose Always, the directory of the .env file -will be added to an allowed list. If a directory is found in this list, the plugin won't ask -for confirmation and will instead source the .env file directly. +a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file +will be added to an allowed list; if you choose Never, it will be added to a disallowed list. +If a directory is found in either of those lists, the plugin won't ask for confirmation and will +instead either source the .env file or proceed without action respectively. -This allowed list is saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list`. If you want -to change that location, change the `$ZSH_DOTENV_ALLOWED_LIST` variable, like so: +The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and +`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location, +change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so: ```zsh # in ~/.zshrc, before Oh My Zsh is sourced: ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list +ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list ``` -This file is just a list of directories allowed, separated by a newline character. If you want -to disallow a directory, just edit this file and remove the line for the directory you want to -disallow. +The file is just a list of directories, separated by a newline character. If you want +to change your decision, just edit the file and remove the line for the directory you want to +change. + +NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list +takes preference, _i.e._ the .env file will never be sourced. ## Version Control diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index ac3210d7f..24f285df5 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -5,6 +5,7 @@ # Path to the file containing allowed paths : ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"} +: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"} ## Functions @@ -14,19 +15,26 @@ source_env() { if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then local confirmation dirpath="${PWD:A}" - # make sure there is an allowed file + # make sure there is an (dis-)allowed file touch "$ZSH_DOTENV_ALLOWED_LIST" + touch "$ZSH_DOTENV_DISALLOWED_LIST" + + # early return if disallowed + if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + return; + fi # check if current directory's .env file is allowed or ask for confirmation if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then # print same-line prompt and output newline character if necessary - echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways) " + echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo # check input case "$confirmation" in [nN]) return ;; [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; + [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; *) ;; # interpret anything else as a yes esac fi -- cgit v1.2.3-70-g09d2 From 55a98fc06d9ea9d003683dec5aae6cb6b0130ab0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 11 Jul 2020 20:02:06 +0200 Subject: git: better algorithm to decide what's the main branch Fixes #9103 Co-authored-by: Yufan You --- plugins/git/git.plugin.zsh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6cae3dac2..7284cd121 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,13 +25,30 @@ function work_in_progress() { fi } -# Check if main exists and use instead of master +# Get the default 'main' branch +# Marc(2020-07-11): I hope to be able to remove this someday function git_main_branch() { - if [[ -n "$(git branch --list master)" ]]; then - echo master - else - echo main + # Get default branch from the origin remote + local branch + branch="${$(command git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)#refs/remotes/origin/}" + + if [[ -n "$branch" ]]; then + echo "$branch" + return fi + + # Look up list of local branches and return the first one that exists + local -a branches + branches=(${(@f)"$(command git for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)"}) + for branch in master main; do + if (( ${branches[(Ie)$branch]} )); then + echo "$branch" + return + fi + done + + echo master + return 1 } # -- cgit v1.2.3-70-g09d2 From 83f61949292b865a7962f1f0a4a8c0fc6350f313 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 11 Jul 2020 20:18:05 +0200 Subject: git: change docs for git_main_branch Also remove unnecesary dramatic remark --- plugins/git/README.md | 14 +++++++------- plugins/git/git.plugin.zsh | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/git/README.md b/plugins/git/README.md index e809e1bcd..b92d0bf02 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -208,13 +208,13 @@ 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: `master` if it exists, `main` 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: from origin or from local branches, else 'master' | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 7284cd121..8f8edcd23 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,8 +25,7 @@ function work_in_progress() { fi } -# Get the default 'main' branch -# Marc(2020-07-11): I hope to be able to remove this someday +# Get the default 'main' branch: from origin, from local branches, or else just 'master' function git_main_branch() { # Get default branch from the origin remote local branch -- cgit v1.2.3-70-g09d2 From 71f0189ed57911360b19883cb6211fe621292086 Mon Sep 17 00:00:00 2001 From: Džiugas Eiva Date: Sat, 11 Jul 2020 21:59:58 +0100 Subject: vscode: add support for VSCodium (#9080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Babak K. Shandiz Co-authored-by: Marc Cornellà --- plugins/vscode/README.md | 32 +++++++++++++++++++++++--------- plugins/vscode/vscode.plugin.zsh | 27 +++++++++++++++++++-------- 2 files changed, 42 insertions(+), 17 deletions(-) (limited to 'plugins') diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md index 469c57ea8..e95ed5d4f 100644 --- a/plugins/vscode/README.md +++ b/plugins/vscode/README.md @@ -1,6 +1,6 @@ # VS Code -This plugin makes interaction between the command line and the VS Code editor easier. +This plugin provides useful aliases to simplify the interaction between the command line and VS Code or VSCodium editor. To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: @@ -10,23 +10,37 @@ plugins=(... vscode) ## Requirements -To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH, -otherwise you might receive this message: `zsh: command not found: code`. +This plugin requires to have a flavour of VS Code installed and it's executable available in PATH. -[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open +You can install either: + +* VS Code (code) +* VS Code Insiders (code-insiders) +* VSCodium (codium) + +### MacOS +While Linux installations will add the executable to PATH, MacOS users might still have to do this manually: + +[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command: -> Install 'code' command in PATH +> Shell Command: Install 'code' command in PATH -## VS Code Insiders +[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal), open +the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command: +> Shell Command: Install 'codium' command in PATH -🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.** +## Using multiple flavours -But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead. +If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can +manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines). +This will make the plugin use your manually defined executable. ```zsh ZSH_THEME=... -# Add this line to use code-insiders instead of code +# Choose between one [code, code-insiders or codium] +# The following line will make the plugin to open VS Code Insiders +# Invalid entries will be ignored, no aliases will be added VSCODE=code-insiders plugins=(... vscode) diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh index 0144e0baa..48d904377 100644 --- a/plugins/vscode/vscode.plugin.zsh +++ b/plugins/vscode/vscode.plugin.zsh @@ -1,17 +1,28 @@ -# VScode zsh plugin +# VS Code (stable / insiders) / VSCodium zsh plugin # Authors: # https://github.com/MarsiBarsi (original author) # https://github.com/babakks +# https://github.com/SteelShot -# Use the stable VS Code release, unless the Insiders version is the only -# available installation -if ! which code > /dev/null && which code-insiders > /dev/null; then - : ${VSCODE:=code-insiders} -else - : ${VSCODE:=code} +# Verify if any manual user choice of VS Code exists first. +if [[ -n "$VSCODE" ]] && ! which $VSCODE &>/dev/null; then + echo "'$VSCODE' flavour of VS Code not detected." + unset VSCODE +fi + +# Otherwise, try to detect a flavour of VS Code. +if [[ -z "$VSCODE" ]]; then + if which code &>/dev/null; then + VSCODE=code + elif which code-insiders &>/dev/null; then + VSCODE=code-insiders + elif which codium &>/dev/null; then + VSCODE=codium + else + return + fi fi -# Define aliases alias vsc="$VSCODE ." alias vsca="$VSCODE --add" alias vscd="$VSCODE --diff" -- cgit v1.2.3-70-g09d2 From 93e9b80d3ff160c7d7f5be4c2c1862da97b273dc Mon Sep 17 00:00:00 2001 From: Alexander Schaber Date: Tue, 14 Jul 2020 16:50:18 +0200 Subject: httpie: add alias for https (#8032) --- plugins/httpie/README.md | 6 ++++++ plugins/httpie/httpie.plugin.zsh | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 plugins/httpie/httpie.plugin.zsh (limited to 'plugins') diff --git a/plugins/httpie/README.md b/plugins/httpie/README.md index 25bdd0c7d..40d60c47d 100644 --- a/plugins/httpie/README.md +++ b/plugins/httpie/README.md @@ -11,4 +11,10 @@ plugins=(... httpie) It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions). +## Aliases + +| Alias | Command | +| ------------ | ---------------------------------------------------------------- | +| `https` | `http --default-scheme=https` | + **Maintainer:** [lululau](https://github.com/lululau) diff --git a/plugins/httpie/httpie.plugin.zsh b/plugins/httpie/httpie.plugin.zsh new file mode 100644 index 000000000..088a1f1cf --- /dev/null +++ b/plugins/httpie/httpie.plugin.zsh @@ -0,0 +1,7 @@ +# +# Aliases +# (sorted alphabetically) +# + +alias https='http --default-scheme=https' + -- cgit v1.2.3-70-g09d2 From 8260005dc7bba42d82edd8e606c10d9e7a9bb26e Mon Sep 17 00:00:00 2001 From: Joaquín Moreira Date: Tue, 14 Jul 2020 11:39:33 -0400 Subject: kubectl: add alias to list pods by namespace (#8604) --- plugins/kubectl/README.md | 3 ++- plugins/kubectl/kubectl.plugin.zsh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index c0db59362..ee05a8af1 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -33,7 +33,8 @@ plugins=(... kubectl) | kep | `kubectl edit pods` | Edit pods from the default editor | | kdp | `kubectl describe pods` | Describe all pods | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | -| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` | +| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | +| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` | | | | **Service management** | | kgs | `kubectl get svc` | List all services in ps output format | | kgsw | `kgs --watch` | After listing all services, watch for changes | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 92688c53c..647d029c1 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -47,6 +47,9 @@ alias kdelp='kubectl delete pods' # get pod by label: kgpl "app=myapp" -n myns alias kgpl='kgp -l' +# get pod by namespace: kgpn kube-system" +alias kgpn='kgp -n' + # Service management. alias kgs='kubectl get svc' alias kgsa='kubectl get svc --all-namespaces' -- cgit v1.2.3-70-g09d2 From 68b98c9d53a4dd0c53d25a9595305e2318af0e2b Mon Sep 17 00:00:00 2001 From: Piotr Zając Date: Tue, 14 Jul 2020 17:40:23 +0200 Subject: docker-compose: add alias for `docker-compose kill` (#8997) --- plugins/docker-compose/README.md | 1 + plugins/docker-compose/docker-compose.plugin.zsh | 1 + 2 files changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index 1105e03f6..a81c2c78e 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -28,3 +28,4 @@ plugins=(... docker-compose) | dclf | `docker-compose logs -f` | Show logs and follow output | | dcpull | `docker-compose pull` | Pull image of a service | | dcstart | `docker-compose start` | Start a container | +| dck | `docker-compose kill` | Kills containers | diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 9ffe1edf6..5b25b63b9 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -24,3 +24,4 @@ alias dcl='docker-compose logs' alias dclf='docker-compose logs -f' alias dcpull='docker-compose pull' alias dcstart='docker-compose start' +alias dck='docker-compose kill' -- cgit v1.2.3-70-g09d2 From ff7618cf744a289a9ba9c332be08ed5304d2f45f Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Wed, 15 Jul 2020 02:53:37 +1000 Subject: timer: threshold to show timers only for time-consuming commands (#8151) --- plugins/timer/README.md | 1 + plugins/timer/timer.plugin.zsh | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/timer/README.md b/plugins/timer/README.md index 321307e59..30b0bd00e 100644 --- a/plugins/timer/README.md +++ b/plugins/timer/README.md @@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa Timer can be tuned by these two variables: * `TIMER_PRECISION` allows to control number of decimal places (default `1`) * `TIMER_FORMAT` allows to adjust display format (default `'/%d'`) +* `TIMER_THRESHOLD` allows to set the minimum execution time that causes the timer to be shown (default `0`) Sample session: diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh index 728377c5c..1be7516a3 100644 --- a/plugins/timer/timer.plugin.zsh +++ b/plugins/timer/timer.plugin.zsh @@ -19,9 +19,11 @@ __timer_display_timer_precmd() { local cmd_end_time=$(__timer_current_time) local tdiff=$((cmd_end_time - __timer_cmd_start_time)) unset __timer_cmd_start_time - local tdiffstr=$(__timer_format_duration ${tdiff}) - local cols=$((COLUMNS - ${#tdiffstr} - 1)) - echo -e "\033[1A\033[${cols}C ${tdiffstr}" + if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then + local tdiffstr=$(__timer_format_duration ${tdiff}) + local cols=$((COLUMNS - ${#tdiffstr} - 1)) + echo -e "\033[1A\033[${cols}C ${tdiffstr}" + fi fi } -- cgit v1.2.3-70-g09d2 From c99f3c50fa46a93be28be88632889404fff3b958 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 15 Jul 2020 17:02:49 +0200 Subject: git: go back to previous main branch detection logic Fixes #9114 --- plugins/git/README.md | 18 +++++++++--------- plugins/git/git.plugin.zsh | 26 +++++--------------------- 2 files changed, 14 insertions(+), 30 deletions(-) (limited to 'plugins') diff --git a/plugins/git/README.md b/plugins/git/README.md index b92d0bf02..b7f216813 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -183,8 +183,8 @@ plugins=(... git) Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means -that any aliases and functions that previously used `master`, will use `main` if `master` doesn't exist. We do this via -the function `git_main_branch`. +that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the +function `git_main_branch`. ### Deprecated aliases @@ -208,13 +208,13 @@ 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: from origin or from local branches, else 'master' | +| 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 | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 8f8edcd23..5a9ccff5c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,29 +25,13 @@ function work_in_progress() { fi } -# Get the default 'main' branch: from origin, from local branches, or else just 'master' +# Check if main exists and use instead of master function git_main_branch() { - # Get default branch from the origin remote - local branch - branch="${$(command git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)#refs/remotes/origin/}" - - if [[ -n "$branch" ]]; then - echo "$branch" - return + if [[ -n "$(git branch --list main)" ]]; then + echo main + else + echo master fi - - # Look up list of local branches and return the first one that exists - local -a branches - branches=(${(@f)"$(command git for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)"}) - for branch in master main; do - if (( ${branches[(Ie)$branch]} )); then - echo "$branch" - return - fi - done - - echo master - return 1 } # -- cgit v1.2.3-70-g09d2 From 322e592c38da2ade0e0db168bb6fdcd3f298600c Mon Sep 17 00:00:00 2001 From: Thi Doãn Date: Sat, 18 Jul 2020 23:32:50 +0900 Subject: extract: add IPA to extractable filetypes (#9117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 81e8e1d23..b2b731e39 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -23,6 +23,7 @@ plugins=(... extract) | `bz2` | Bzip2 file | | `deb` | Debian package | | `gz` | Gzip file | +| `ipa` | iOS app package | | `ipsw` | iOS firmware file | | `jar` | Java Archive | | `lrz` | LRZ archive | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 1a263a744..f96f0d450 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|gz|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|deb|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 a5594b81a..46e69f08d 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|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.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" ;; -- cgit v1.2.3-70-g09d2 From a3740c34148a7a44d82683d2aa31c98f32b21a96 Mon Sep 17 00:00:00 2001 From: Samuel Terra Date: Sat, 18 Jul 2020 13:45:59 -0300 Subject: battery: add acpi requirement to README (#9116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/battery/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/battery/README.md b/plugins/battery/README.md index b7a13a7ec..c2554a36d 100644 --- a/plugins/battery/README.md +++ b/plugins/battery/README.md @@ -9,5 +9,14 @@ To use, add `battery` to the list of plugins in your `.zshrc` file: Then, add the `battery_pct_prompt` function to your custom theme. For example: ``` -RPROMPT='$(battery_pct_prompt)' +RPROMPT='$(battery_pct_prompt) ...' +``` + +## Requirements + +On Linux, you must have the `acpi` tool installed on your operating system. + +Here's an example of how to install with apt: +``` +sudo apt-get install acpi ``` -- cgit v1.2.3-70-g09d2 From db3d05fe7184a523fe4aba120bea962114424573 Mon Sep 17 00:00:00 2001 From: Amir Tahvildaran Date: Sat, 18 Jul 2020 13:06:08 -0400 Subject: aws: improve check for aws_completer - unhardcode path (#9123) Closes #9122 The current check is assuming that the aws_completer is installed globally, it then runs the command without that path I have aws_completer in ~/.local/bin/aws_completer This changes the check to see if the command exists instead of concerning itself with where it in installed. This test matches the behavior of just running the command. --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d00c2e56c..7994963c3 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -63,7 +63,7 @@ fi # Load awscli completions # AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back -if [[ -x /usr/local/bin/aws_completer ]]; then +if command -v aws_completer &> /dev/null; then autoload -Uz bashcompinit && bashcompinit complete -C aws_completer aws else -- cgit v1.2.3-70-g09d2