From 56297902e9d0f7a14f6d4d88b24eaea7392f3c32 Mon Sep 17 00:00:00 2001 From: Andras Svraka Date: Thu, 16 Jan 2020 18:19:56 +0100 Subject: lib: add MSYS2 support to clipboard integration (#8542) --- lib/clipboard.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 2c93d1bb5..5bba11d16 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -24,7 +24,7 @@ function clipcopy() { else cat $file | pbcopy fi - elif [[ $OSTYPE == cygwin* ]]; then + elif [[ $OSTYPE == (cygwin|msys)* ]]; then if [[ -z $file ]]; then cat > /dev/clipboard else @@ -71,7 +71,7 @@ function clippaste() { emulate -L zsh if [[ $OSTYPE == darwin* ]]; then pbpaste - elif [[ $OSTYPE == cygwin* ]]; then + elif [[ $OSTYPE == (cygwin|msys)* ]]; then cat /dev/clipboard else if (( $+commands[xclip] )); then -- cgit v1.2.3-70-g09d2 From ce298d090b737cbce2a87afaada2195b0bb2e801 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jan 2020 13:39:18 +0100 Subject: yarn: use zsh-completions latest version (493984e) --- plugins/yarn/_yarn | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn index 3689ae960..70e783b86 100644 --- a/plugins/yarn/_yarn +++ b/plugins/yarn/_yarn @@ -86,9 +86,11 @@ _yarn_scripts() { local i runJSON runJSON=$(yarn run --json 2>/dev/null) - binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON")) - scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON")) - scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{([^}]+)\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\n/g;s/(^"|"$)//g' <<< "$runJSON")}") + # Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement + # pattern as a newline. See https://superuser.com/q/307165 + binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON")) + scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON")) + scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}") for (( i=1; i <= $#scriptNames; i++ )); do scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}") -- cgit v1.2.3-70-g09d2 From 530056d50d63b67dfaa169e2600a7c600ea18aa1 Mon Sep 17 00:00:00 2001 From: James Wright Date: Sun, 19 Jan 2020 09:47:28 -0700 Subject: colored-man-pages: force `env` command (#8551) Invoke `env` via `command` to ignore shell functions and aliases. --- plugins/colored-man-pages/colored-man-pages.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index ac6a94654..f74105d40 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -17,7 +17,7 @@ EOF fi function colored() { - env \ + command env \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_me=$(printf "\e[0m") \ -- cgit v1.2.3-70-g09d2 From a04728f1681ca2a185245fb9f6f6eb869c113ad0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jan 2020 17:52:15 +0100 Subject: init: force use of builtin test in is_plugin Fixes #8545 --- oh-my-zsh.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 6b2662d5e..c3fae6efb 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -32,8 +32,8 @@ fi is_plugin() { local base_dir=$1 local name=$2 - test -f $base_dir/plugins/$name/$name.plugin.zsh \ - || test -f $base_dir/plugins/$name/_$name + builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \ + || builtin test -f $base_dir/plugins/$name/_$name } # Add all defined plugins to fpath. This must be done -- cgit v1.2.3-70-g09d2 From 4e45e12dc355e3ba34e7e40ce4936fb222f0155c Mon Sep 17 00:00:00 2001 From: Jimmy Merrild Krag Date: Sun, 19 Jan 2020 20:42:45 +0100 Subject: virtualenvwrapper: fix finding script on Ubuntu 19.10 (#8451) --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index b07b2a306..b2d2c5cd6 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -22,6 +22,13 @@ elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh" source "/usr/local/bin/virtualenvwrapper.sh" } +elif [[ -f "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" ]]; then + function { + setopt local_options + unsetopt equals + virtualenvwrapper="/usr/share/virtualenvwrapper/virtualenvwrapper.sh" + source "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" + } elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then function { setopt local_options -- cgit v1.2.3-70-g09d2 From 64a7f6b38833d007394b9b4bf5d17e48db77c0d7 Mon Sep 17 00:00:00 2001 From: Modded Gamers <35778371+ModdedGamers@users.noreply.github.com> Date: Tue, 28 Jan 2020 18:22:27 -0500 Subject: Create Github Action to run tests (#8569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The published workflow tests the installer and checks the syntax of known zsh files in the project. Co-authored-by: Marc Cornellà --- .github/workflows/check-suite.yml | 36 ++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/check-suite.yml diff --git a/.github/workflows/check-suite.yml b/.github/workflows/check-suite.yml new file mode 100644 index 000000000..3a7ad354d --- /dev/null +++ b/.github/workflows/check-suite.yml @@ -0,0 +1,36 @@ +name: Check Suite +on: + pull_request: + types: + - opened + - synchronize + branches: + - master + push: + branches: + - master + +jobs: + tests: + name: Run tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Set up git repository + uses: actions/checkout@v2 + - name: Install zsh + if: runner.os == 'Linux' + run: sudo apt-get update; sudo apt-get install zsh + - name: Test installer + run: sh ./tools/install.sh + - name: Check syntax + run: | + for file in ./oh-my-zsh.sh \ + ./lib/*.zsh \ + ./plugins/*/*.plugin.zsh \ + ./plugins/*/_* \ + ./themes/*.zsh-theme; do + zsh -n "$file" || return 1 + done diff --git a/README.md b/README.md index 291fb512b..fddc7c241 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Finally, you'll begin to get the sort of attention that you have always felt you To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord. +![Check Suite](https://github.com/ohmyzsh/ohmyzsh/workflows/Check%20Suite/badge.svg) [![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) [![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN) -- cgit v1.2.3-70-g09d2 From 7ff77120c17b83ca1c5d4939d21c1a84a4b2ffbb Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 29 Jan 2020 16:21:40 +0330 Subject: vscode: use insiders build if stable not found (#8568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔨 Add calling VS Code Insiders * ✏️ Update README.md --- plugins/vscode/README.md | 12 +++++++----- plugins/vscode/vscode.plugin.zsh | 14 +++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md index 74b5a45aa..2c6530650 100644 --- a/plugins/vscode/README.md +++ b/plugins/vscode/README.md @@ -1,6 +1,6 @@ -# VS code +# VS Code -This plugin makes interaction between the command line and the code editor easier. +This plugin makes interaction between the command line and the VS Code editor easier. To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: @@ -8,9 +8,11 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc` plugins=(... vscode) ``` -If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/), -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. +## VS Code Insiders + +🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.** + +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. ```zsh ZSH_THEME=... diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh index 4c15df2b0..0144e0baa 100644 --- a/plugins/vscode/vscode.plugin.zsh +++ b/plugins/vscode/vscode.plugin.zsh @@ -1,9 +1,17 @@ # VScode zsh plugin -# author: https://github.com/MarsiBarsi +# Authors: +# https://github.com/MarsiBarsi (original author) +# https://github.com/babakks -# Use main Visual Studio Code version by default -: ${VSCODE:=code} +# 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} +fi +# Define aliases alias vsc="$VSCODE ." alias vsca="$VSCODE --add" alias vscd="$VSCODE --diff" -- cgit v1.2.3-70-g09d2 From 05a38c8b99ea5bc54e7fdfc1cc1ea6d2729c05e5 Mon Sep 17 00:00:00 2001 From: Nikita Sharnin <43130421+HikiShi@users.noreply.github.com> Date: Wed, 29 Jan 2020 21:28:34 +0600 Subject: lol: fix docs for yolo alias (#8576) --- plugins/lol/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lol/README.md b/plugins/lol/README.md index 8fba7b713..1791de493 100644 --- a/plugins/lol/README.md +++ b/plugins/lol/README.md @@ -61,7 +61,7 @@ Plugin for adding catspeak aliases, because why not | `violenz` | `git rebase` | | `visible` | `echo` | | `wtf` | `dmesg` | -| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` | +| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` | ## Usage Examples @@ -78,6 +78,6 @@ nowai u=r,go= some.file # ssh root@catserver.org pwned root@catserver.org -# git commit -m "$(curl -s https://whatthecommit.com/index.txt)" +# git commit -m "$(curl -s http://whatthecommit.com/index.txt)" yolo ``` -- cgit v1.2.3-70-g09d2 From dcffc895806f5c2aaade3fce09772e1c9f52504e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 30 Jan 2020 13:31:33 +0100 Subject: aws: fix array assignment in asp function Older zsh versions require this syntax change. Fixes #8525 --- plugins/aws/aws.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 231ac5ad2..567311372 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -10,7 +10,8 @@ function asp() { return fi - local available_profiles=($(aws_profiles)) + local -a available_profiles + available_profiles=($(aws_profiles)) if [[ -z "${available_profiles[(r)$1]}" ]]; then echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 -- cgit v1.2.3-70-g09d2 From 69caf98cf754553fda969b0bf1d4966f0498f58f Mon Sep 17 00:00:00 2001 From: Dennis Rausch Date: Thu, 30 Jan 2020 18:32:53 -0600 Subject: fix: Update tmux plugin to use modern terminfo. (#8582) * fix: Update tmux plugin to use modern terminfo. * doc: Update documentation for tmux plugin. --- plugins/tmux/README.md | 4 ++-- plugins/tmux/tmux.plugin.zsh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index db57f5be2..86a95bd4f 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -35,7 +35,7 @@ The plugin also supports the following - | `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | | `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | | `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | -| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | -| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | +| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux`) | +| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `tmux-256color` | | `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) | | `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index e52443a71..5ee37dff0 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -22,18 +22,18 @@ alias tkss='tmux kill-session -t' : ${ZSH_TMUX_AUTOCONNECT:=true} # Automatically close the terminal when tmux exits : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} -# Set term to screen or screen-256color based on current terminal support +# Set term to tmux or tmux-256color based on current terminal support : ${ZSH_TMUX_FIXTERM:=true} # Set '-CC' option for iTerm2 tmux integration : ${ZSH_TMUX_ITERM2:=false} # The TERM to use for non-256 color terminals. -# Tmux states this should be screen, but you may need to change it on +# Tmux states this should be tmux, but you may need to change it on # systems without the proper terminfo -: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen} +: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux} # The TERM to use for 256 color terminals. -# Tmux states this should be screen-256color, but you may need to change it on +# Tmux states this should be tmux-256color, but you may need to change it on # systems without the proper terminfo -: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color} +: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color} # Set the configuration path : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} # Set -u option to support unicode -- cgit v1.2.3-70-g09d2 From df56d1ee1fb7430d8979973300bf0c6b53a5446c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 4 Feb 2020 13:02:20 +0100 Subject: Rename GitHub Action to CI --- .github/workflows/check-suite.yml | 36 ------------------------------------ .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/check-suite.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/check-suite.yml b/.github/workflows/check-suite.yml deleted file mode 100644 index 3a7ad354d..000000000 --- a/.github/workflows/check-suite.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Check Suite -on: - pull_request: - types: - - opened - - synchronize - branches: - - master - push: - branches: - - master - -jobs: - tests: - name: Run tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - name: Set up git repository - uses: actions/checkout@v2 - - name: Install zsh - if: runner.os == 'Linux' - run: sudo apt-get update; sudo apt-get install zsh - - name: Test installer - run: sh ./tools/install.sh - - name: Check syntax - run: | - for file in ./oh-my-zsh.sh \ - ./lib/*.zsh \ - ./plugins/*/*.plugin.zsh \ - ./plugins/*/_* \ - ./themes/*.zsh-theme; do - zsh -n "$file" || return 1 - done diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..7ab7efdd6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: CI +on: + pull_request: + types: + - opened + - synchronize + branches: + - master + push: + branches: + - master + +jobs: + tests: + name: Run tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Set up git repository + uses: actions/checkout@v2 + - name: Install zsh + if: runner.os == 'Linux' + run: sudo apt-get update; sudo apt-get install zsh + - name: Test installer + run: sh ./tools/install.sh + - name: Check syntax + run: | + for file in ./oh-my-zsh.sh \ + ./lib/*.zsh \ + ./plugins/*/*.plugin.zsh \ + ./plugins/*/_* \ + ./themes/*.zsh-theme; do + zsh -n "$file" || return 1 + done diff --git a/README.md b/README.md index fddc7c241..d36591abc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Finally, you'll begin to get the sort of attention that you have always felt you To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord. -![Check Suite](https://github.com/ohmyzsh/ohmyzsh/workflows/Check%20Suite/badge.svg) +![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg) [![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) [![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN) -- cgit v1.2.3-70-g09d2 From 578b0860112af83af25afb687887109748a03c08 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 4 Feb 2020 13:07:40 +0100 Subject: Link to Actions page in GitHub Action badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d36591abc..187cceb7d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Finally, you'll begin to get the sort of attention that you have always felt you To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord. -![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg) +[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI) [![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) [![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN) -- cgit v1.2.3-70-g09d2 From 6bebc254e88ac9b7fdaa7491d031f82ec107e418 Mon Sep 17 00:00:00 2001 From: Aliaksei Maiseyeu Date: Tue, 4 Feb 2020 15:27:18 +0300 Subject: af-magic: fix showing aws prompt out of the box (#8243) Fix issue related to #7615, #7747 and #6346 After the update, aws prompt (which should be visible out of the box) disappears when a user uses a theme af-magic, because of fact that plugins are loaded before themes. This pull request fixes issue with not showing aws prompt in theme af-magic, by appending RPROMPT in theme af-magic instead overwriting. --- themes/af-magic.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index d185fa1ab..30e997f8c 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -21,9 +21,9 @@ eval my_orange='$FG[214]' # right prompt if type "virtualenv_prompt_info" > /dev/null then - RPROMPT='$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%' + RPROMPT="${RPROMPT}"'$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%' else - RPROMPT='$my_gray%n@%m%{$reset_color%}%' + RPROMPT="${RPROMPT}"'$my_gray%n@%m%{$reset_color%}%' fi # git settings -- cgit v1.2.3-70-g09d2 From 77aa1795d2f05583d4fc63a63abb0144beb5ecff Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 4 Feb 2020 19:41:39 +0100 Subject: Revert "fix: Update tmux plugin to use modern terminfo. (#8582)" This reverts commit 69caf98cf754553fda969b0bf1d4966f0498f58f. --- plugins/tmux/README.md | 4 ++-- plugins/tmux/tmux.plugin.zsh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 86a95bd4f..db57f5be2 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -35,7 +35,7 @@ The plugin also supports the following - | `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | | `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | | `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | -| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux`) | -| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `tmux-256color` | +| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | +| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | | `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) | | `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 5ee37dff0..e52443a71 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -22,18 +22,18 @@ alias tkss='tmux kill-session -t' : ${ZSH_TMUX_AUTOCONNECT:=true} # Automatically close the terminal when tmux exits : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} -# Set term to tmux or tmux-256color based on current terminal support +# Set term to screen or screen-256color based on current terminal support : ${ZSH_TMUX_FIXTERM:=true} # Set '-CC' option for iTerm2 tmux integration : ${ZSH_TMUX_ITERM2:=false} # The TERM to use for non-256 color terminals. -# Tmux states this should be tmux, but you may need to change it on +# Tmux states this should be screen, but you may need to change it on # systems without the proper terminfo -: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux} +: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen} # The TERM to use for 256 color terminals. -# Tmux states this should be tmux-256color, but you may need to change it on +# Tmux states this should be screen-256color, but you may need to change it on # systems without the proper terminfo -: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color} +: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color} # Set the configuration path : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} # Set -u option to support unicode -- cgit v1.2.3-70-g09d2 From e81782ac3faf24cac2384a99366f748040b3f20a Mon Sep 17 00:00:00 2001 From: Alastair Rankine Date: Fri, 7 Feb 2020 06:06:06 -0500 Subject: virtualenvwrapper: rewrite init script location code (#8521) --- .../virtualenvwrapper/virtualenvwrapper.plugin.zsh | 64 +++++++--------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index b2d2c5cd6..267bcaeb5 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,55 +1,29 @@ -virtualenvwrapper='virtualenvwrapper.sh' -virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh' +function { + # search in these locations for the init script: + for f in $commands[virtualenvwrapper_lazy.sh] \ + $commands[virtualenvwrapper.sh] \ + /usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \ + /usr/local/bin/virtualenvwrapper{_lazy,}.sh \ + /etc/bash_completion.d/virtualenvwrapper \ + /usr/share/bash-completion/completions/virtualenvwrapper + do + if [[ -f $f ]]; then + source $f + return + fi + done + print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\ + "Please install with \`pip install virtualenvwrapper\`" >&2 +} -if (( $+commands[$virtualenvwrapper_lazy] )); then - function { - setopt local_options - unsetopt equals - virtualenvwrapper=${${virtualenvwrapper_lazy}:c} - source ${${virtualenvwrapper_lazy}:c} - [[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs" - } -elif (( $+commands[$virtualenvwrapper] )); then - function { - setopt local_options - unsetopt equals - source ${${virtualenvwrapper}:c} - } -elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then - function { - setopt local_options - unsetopt equals - virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh" - source "/usr/local/bin/virtualenvwrapper.sh" - } -elif [[ -f "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" ]]; then - function { - setopt local_options - unsetopt equals - virtualenvwrapper="/usr/share/virtualenvwrapper/virtualenvwrapper.sh" - source "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" - } -elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then - function { - setopt local_options - unsetopt equals - virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper" - source "/etc/bash_completion.d/virtualenvwrapper" - } -else - print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\ - "Please install with \`pip install virtualenvwrapper\`" >&2 - return -fi if ! type workon &>/dev/null; then print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ "Please check ${virtualenvwrapper}" >&2 return fi -if [[ "$WORKON_HOME" == "" ]]; then - print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2 - return +if [[ -z "$WORKON_HOME" ]]; then + WORKON_HOME="$HOME/.virtualenvs" fi if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then -- cgit v1.2.3-70-g09d2 From beab76edfce3500b2fb357c69f3d4fb2a17898fe Mon Sep 17 00:00:00 2001 From: Larson Carter Date: Fri, 13 Dec 2019 08:18:25 -0600 Subject: Update issues and PR templates (#8471) Closes #8471 --- .github/ISSUE_TEMPLATE/bug_report.md | 32 +++++++++++++++---------------- .github/ISSUE_TEMPLATE/feature_request.md | 10 +++++----- .github/ISSUE_TEMPLATE/support.md | 2 -- .github/PULL_REQUEST_TEMPLATE.md | 17 ++++++++++++++++ 4 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 076c35544..7c1cb8967 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,7 @@ --- name: Bug report -about: Create a report to help us improve +about: Create a report to help us improve Oh My Zsh +labels: 'Type: support' --- @@ -10,29 +11,26 @@ an issue where no sections have been filled will be deleted without comment. --> **Describe the bug** - +A clear description of what the bug is. **To Reproduce** - **Expected behavior** - +A brief description of what should happen. -**Screenshots or recordings** - +**Screenshots and/or Recordings** +If applicable, add screenshots to help explain your problem. +You can also record an asciinema session: https://asciinema.org/ -**System:** - - OS: [e.g. macOS] - - Zsh version [e.g. 5.6] +**Desktop (please complete the following information):** + - OS / Distro: [e.g. Arch Linux, macOS] + - Latest ohmyzsh Update?: [e.g. Yes/No] + - ZSH Version: [e.g. 5.6] - Terminal emulator [e.g. iTerm2] **Additional context** - +Add any other context about the problem here. This can be themes, plugins, custom configs. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index d9c324a55..346eabaea 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment. --> **Is your feature request related to a particular plugin or theme? If so, specify it.** - +The name of the plugin or theme that you would like us to improve. [...] **Is your feature request related to a problem? Please describe.** - +A description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** - +A description of what you want to happen. **Describe alternatives you've considered** - +A description of any alternative solutions or features you've considered. This can also include other plugins or aliases. **Additional context** - +Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md index 3c69a7d5e..d2638412e 100644 --- a/.github/ISSUE_TEMPLATE/support.md +++ b/.github/ISSUE_TEMPLATE/support.md @@ -5,8 +5,6 @@ labels: 'Type: support' --- - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..6bcb90efe --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +## Standards checklist: + +- [ ] The PR title is descriptive. +- [ ] The PR doesn't replicate another PR which is already open. +- [ ] I have read the contribution guide and followed all the instructions. +- [ ] The code follows the code style guide detailed in the wiki. +- [ ] 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. + +## Changes: + +- [...] + +## Other comments: + +... -- cgit v1.2.3-70-g09d2 From bfec31666aa9e61cc869fa6e93a031b53fe47d44 Mon Sep 17 00:00:00 2001 From: Petr Šabata Date: Mon, 10 Feb 2020 19:16:02 +0100 Subject: systemd: refactor and add latest commands (#6250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Order systemctl commands alphabetically Simplifying the plugin maintenance. Signed-off-by: Petr Šabata * Include the latest systemctl commands Based on systemd-233. I'm still keeping the old, now unsupported commands for backwards compatibility as well. Signed-off-by: Petr Šabata * Add daemon-reload (#3701) Closes #3701 Co-authored-by: Javier Tia --- plugins/systemd/systemd.plugin.zsh | 65 ++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 7cd27d450..201ffd998 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -1,12 +1,65 @@ user_commands=( - list-units is-active status show help list-unit-files - is-enabled list-jobs show-environment cat list-timers) + cat + get-default + help + is-active + is-enabled + is-failed + is-system-running + list-dependencies + list-jobs + list-sockets + list-timers + list-unit-files + list-units + show + show-environment + status) sudo_commands=( - start stop reload restart try-restart isolate kill - reset-failed enable disable reenable preset mask unmask - link load cancel set-environment unset-environment - edit) + add-requires + add-wants + cancel + daemon-reexec + daemon-reload + default + disable + edit + emergency + enable + halt + hibernate + hybrid-sleep + import-environment + isolate + kexec + kill + link + list-machines + load + mask + poweroff + preset + preset-all + reboot + reenable + reload + reload-or-restart + reset-failed + rescue + restart + revert + set-default + set-environment + set-property + start + stop + suspend + switch-root + try-reload-or-restart + try-restart + unmask + unset-environment) for c in $user_commands; do; alias sc-$c="systemctl $c"; done for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done -- cgit v1.2.3-70-g09d2 From 22cf7159ec09722421ffe355e852410823d7f49d Mon Sep 17 00:00:00 2001 From: Isaac Cook Date: Mon, 10 Feb 2020 13:31:55 -0600 Subject: kube-ps1: add example for common pitfall (#8318) I ran into this issue, looks like maybe a few other people did as well. https://github.com/jonmosco/kube-ps1/issues/28#issuecomment-359761463 A simple clarification seems helpful. --- plugins/kube-ps1/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md index 82c0a77e6..fdc1a94e8 100644 --- a/plugins/kube-ps1/README.md +++ b/plugins/kube-ps1/README.md @@ -55,6 +55,8 @@ plugins=( # After the "source Oh My Zsh" line PROMPT=$PROMPT'$(kube_ps1) ' +# Or in double quotes, don't forget to escape +PROMPT=$PROMPT"\$(kube_ps1) " ``` Note: The `PROMPT` example above was tested with the theme `robbyrussell`. -- cgit v1.2.3-70-g09d2 From 1c300d3a76a786a83e8a70b7a399db94c8bcf5b7 Mon Sep 17 00:00:00 2001 From: Evan Chiu Date: Sun, 10 Apr 2016 17:32:37 -0700 Subject: lib: add git function to determine repository name (#4989) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4989 Co-authored-by: Marc Cornellà --- lib/git.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 2054fe272..00cb00b19 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -199,3 +199,12 @@ function git_current_user_name() { function git_current_user_email() { command git config user.email 2>/dev/null } + +# Output the name of the root directory of the git repository +# Usage example: $(git_repo_name) +function git_repo_name() { + local repo_path + if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then + echo ${repo_path:t} + fi +} -- cgit v1.2.3-70-g09d2 From d88fbe625f0a7c6f7296a58e0cd919903cd81511 Mon Sep 17 00:00:00 2001 From: Grégory DAVID <632571+groolot@users.noreply.github.com> Date: Mon, 10 Feb 2020 21:18:14 +0100 Subject: systemadmin: fix header line sorting in pscpu (#6167) Inside `pscpu` and `pscpu10` aliases, remove sorting of the header line. --- plugins/systemadmin/systemadmin.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index bdc2219fa..ded25c3a9 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -28,8 +28,8 @@ alias mkdir='mkdir -pv' alias psmem='ps -e -orss=,args= | sort -b -k1,1n' alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10' # get top process eating cpu if not work try excute : export LC_ALL='C' -alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr' -alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10' +alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr' +alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10' # top10 of the history alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' -- cgit v1.2.3-70-g09d2 From f362b69df696866704fc1b0b1bcb9a7d2a780b2a Mon Sep 17 00:00:00 2001 From: Yuan Liu Date: Mon, 10 Feb 2020 12:19:03 -0800 Subject: common-aliases: fix loading of is-at-least function (#6215) --- plugins/common-aliases/common-aliases.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 785a09c63..ce1995c03 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -50,6 +50,7 @@ alias mv='mv -i' # zsh is able to auto-do some kungfoo # depends on the SUFFIX :) +autoload -Uz is-at-least if is-at-least 4.2.0; then # open browser on urls if [[ -n "$BROWSER" ]]; then -- cgit v1.2.3-70-g09d2 From 83aa984d1a11199d5bb23fb1e462f48e9b4edc88 Mon Sep 17 00:00:00 2001 From: Henry Darnell Date: Mon, 10 Feb 2020 18:39:20 -0600 Subject: Add dotnet watch and dotnet watch run (#8612) --- plugins/dotnet/README.md | 20 +++++++++++--------- plugins/dotnet/dotnet.plugin.zsh | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md index 7a6d6a995..a663fc88d 100644 --- a/plugins/dotnet/README.md +++ b/plugins/dotnet/README.md @@ -10,12 +10,14 @@ plugins=(... dotnet) ## Aliases -| Alias | Command | Description | -|-------|--------------|-------------------------------------------------------------------| -| dn | dotnet new | Create a new .NET project or file. | -| dr | dotnet run | Build and run a .NET project output. | -| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. | -| ds | dotnet sln | Modify Visual Studio solution files. | -| da | dotnet add | Add a package or reference to a .NET project. | -| dp | dotnet pack | Create a NuGet package. | -| dng | dotnet nuget | Provides additional NuGet commands. | \ No newline at end of file +| Alias | Command | Description | +|-------|------------------|-------------------------------------------------------------------| +| dn | dotnet new | Create a new .NET project or file. | +| dr | dotnet run | Build and run a .NET project output. | +| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. | +| dw | dotnet watch | Watch for source file changes and restart the dotnet command. | +| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. | +| ds | dotnet sln | Modify Visual Studio solution files. | +| da | dotnet add | Add a package or reference to a .NET project. | +| dp | dotnet pack | Create a NuGet package. | +| dng | dotnet nuget | Provides additional NuGet commands. | \ No newline at end of file diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index 8b9a45a97..ed6c68e5d 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -111,6 +111,8 @@ compdef _dotnet dotnet # --------------------------------------------------------------------- # alias dr='dotnet run' alias dt='dotnet test' +alias dw='dotnet watch' +alias dwr='dotnet watch run' alias ds='dotnet sln' alias da='dotnet add' alias dp='dotnet pack' -- cgit v1.2.3-70-g09d2 From 05cae34676ac3a22fb8a0adca8ab9b5301f48fb9 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 17:43:59 +0100 Subject: Detect dependency plugins in candy-kingdom and kiwi themes Fixes #5029 Fixes #5342 --- themes/candy-kingdom.zsh-theme | 24 +++++++++++++----------- themes/kiwi.zsh-theme | 4 +--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme index 30ce785c0..ad03cc320 100644 --- a/themes/candy-kingdom.zsh-theme +++ b/themes/candy-kingdom.zsh-theme @@ -1,16 +1,14 @@ -# neuralsanwich.zsh-theme - -if [ "x$OH_MY_ZSH_HG" = "x" ]; then - OH_MY_ZSH_HG="hg" -fi - -function hg_prompt_info { - $OH_MY_ZSH_HG prompt --angle-brackets "\ +if ! hg prompt 2>/dev/null; then + function hg_prompt_info { } +else + function hg_prompt_info { + hg prompt --angle-brackets "\ < on %{$fg[magenta]%}%{$reset_color%}>\ < at %{$fg[yellow]%}%{$reset_color%}>\ %{$fg[green]%}%{$reset_color%}< patches: >" 2>/dev/null -} + } +fi function box_name { [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST} @@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" -local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}" -RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}' +RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}' + +# Add battery status if the battery plugin is enabled +if (( $+functions[battery_pct_prompt] )); then + RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}' +fi diff --git a/themes/kiwi.zsh-theme b/themes/kiwi.zsh-theme index f93de2b75..94f0ffcbf 100644 --- a/themes/kiwi.zsh-theme +++ b/themes/kiwi.zsh-theme @@ -1,6 +1,4 @@ -# -# Kiwi ZSH Theme -# +(( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { } PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt) └> % %{$reset_color%}' -- cgit v1.2.3-70-g09d2 From 9dffb3191d5d87509830bcf5367551c2637827bb Mon Sep 17 00:00:00 2001 From: Umberto Nicoletti Date: Tue, 11 Feb 2020 18:46:56 +0100 Subject: vagrant: obey VAGRANT_CWD when completing vagrant commands (#7219) --- plugins/vagrant/_vagrant | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index 2efb4473d..79c4c6fe6 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -69,8 +69,8 @@ __box_list () __vm_list () { - _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') - _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null) + _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') + _wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null) } __vagrant-box () -- cgit v1.2.3-70-g09d2 From bc67a55fe8ff6fce8fdc2c002dbb7159c6008aa0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 19:35:17 +0100 Subject: jump: fix issues in plugin and document CTRL+G key binding - Fixes `readlink -e` dependency which isn't supported in macOS (fixes #3235). - Uses native zsh wildcard expansion instead of calls to `ls`. - Prepends commands with `command` and `builtin` to bypass aliases and functions. - Documents CTRL+G key binding to substitute mark name in the command line with the mark path (https://github.com/ohmyzsh/ohmyzsh/pull/2045#issuecomment-22826540). --- plugins/jump/README.md | 12 ++++++++++++ plugins/jump/jump.plugin.zsh | 21 ++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/plugins/jump/README.md b/plugins/jump/README.md index ed6415289..1b0ce68c0 100644 --- a/plugins/jump/README.md +++ b/plugins/jump/README.md @@ -17,3 +17,15 @@ plugins=(... jump) | `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided | | `unmark ` | Remove the given mark | | `marks` | List the existing marks and the directories they point to | + +## Key bindings + +Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark. +For example, with a mark named `mymark` pointing to `/path/to/my/mark`: +```zsh +$ cp /tmp/file mymark +``` +will become: +```zsh +$ cp /tmp/file /path/to/my/mark +``` diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index d161a6da0..4f9134fcd 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -9,22 +9,23 @@ export MARKPATH=$HOME/.marks jump() { - cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} + builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} } mark() { - if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then - MARK=$(basename "$PWD") + if [[ $# -eq 0 || "$1" = "." ]]; then + MARK=${PWD:t} else MARK="$1" fi - if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then - mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK" + if read -q "?Mark $PWD as ${MARK}? (y/n) "; then + command mkdir -p "$MARKPATH" + command ln -sfn "$PWD" "$MARKPATH/$MARK" fi } unmark() { - rm -i "$MARKPATH/$1" + LANG= command rm -i "$MARKPATH/$1" } marks() { @@ -44,13 +45,7 @@ marks() { } _completemarks() { - if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then - reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g')) - else - if readlink -e "${MARKPATH}"/* &>/dev/null; then - reply=($(ls "${MARKPATH}")) - fi - fi + reply=("${MARKPATH}"/*(N:t)) } compctl -K _completemarks jump compctl -K _completemarks unmark -- cgit v1.2.3-70-g09d2 From 3c5bbcf5b99d2b7dc0cbba6d154328344633bd72 Mon Sep 17 00:00:00 2001 From: hqingyi Date: Fri, 27 Nov 2015 19:29:15 +0800 Subject: jump: add support for directories starting with a dot (#4661) Closes #4661 --- plugins/jump/jump.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 4f9134fcd..a21b7a181 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -29,14 +29,14 @@ unmark() { } marks() { - local max=0 - for link in $MARKPATH/*(@); do + local link max=0 + for link in $MARKPATH/{,.}*(@); do if [[ ${#link:t} -gt $max ]]; then max=${#link:t} fi done local printf_markname_template="$(printf -- "%%%us " "$max")" - for link in $MARKPATH/*(@); do + for link in $MARKPATH/{,.}*(@); do local markname="$fg[cyan]${link:t}$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" printf -- "$printf_markname_template" "$markname" @@ -45,13 +45,13 @@ marks() { } _completemarks() { - reply=("${MARKPATH}"/*(N:t)) + reply=("${MARKPATH}"/{,.}*(@N:t)) } compctl -K _completemarks jump compctl -K _completemarks unmark _mark_expansion() { - setopt extendedglob + setopt localoptions extendedglob autoload -U modify-current-argument modify-current-argument '$(readlink "$MARKPATH/$ARG")' } -- cgit v1.2.3-70-g09d2 From 561e7169acd02d5e27542a1d93f1f9533ba52fa6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 20:12:01 +0100 Subject: jump: fix for `marks' and CTRL+G key binding - marks printed an error when $MARKPATH didn't exist or didn't have any marks in it. - The CTRL+G key binding overwrote an argument when it couldn't match it to an existing mark. --- plugins/jump/jump.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index a21b7a181..c2da1144e 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -30,13 +30,13 @@ unmark() { marks() { local link max=0 - for link in $MARKPATH/{,.}*(@); do + for link in $MARKPATH/{,.}*(@N); do if [[ ${#link:t} -gt $max ]]; then max=${#link:t} fi done local printf_markname_template="$(printf -- "%%%us " "$max")" - for link in $MARKPATH/{,.}*(@); do + for link in $MARKPATH/{,.}*(@N); do local markname="$fg[cyan]${link:t}$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" printf -- "$printf_markname_template" "$markname" @@ -53,7 +53,7 @@ compctl -K _completemarks unmark _mark_expansion() { setopt localoptions extendedglob autoload -U modify-current-argument - modify-current-argument '$(readlink "$MARKPATH/$ARG")' + modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")' } zle -N _mark_expansion bindkey "^g" _mark_expansion -- cgit v1.2.3-70-g09d2 From 17428f3c9a99c8d81e57bcf565d39011669e65ed Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 20:16:43 +0100 Subject: lib: load bash completion functions automatically Fixes #8614 --- lib/completion.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/completion.zsh b/lib/completion.zsh index c7db2eb7b..c932bc925 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then zle -N expand-or-complete-with-dots bindkey "^I" expand-or-complete-with-dots fi + +# automatically load bash completion functions +autoload -Uz bashcompinit && bashcompinit -- cgit v1.2.3-70-g09d2 From 1bd7a7ad21c51268ba0f9a0d8b643a82b5788a6a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 13:32:13 +0100 Subject: Fix calculation for battery percentage (#4774) Co-authored-by: Michael Wolman --- plugins/battery/battery.plugin.zsh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 6b6684716..5322dd18a 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -169,8 +169,8 @@ fi function battery_level_gauge() { local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; - local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; - local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; + local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}; + local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}; local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; local color_red=${BATTERY_COLOR_RED:-%F{red}}; @@ -183,26 +183,35 @@ function battery_level_gauge() { local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; local battery_remaining_percentage=$(battery_pct); + local filled empty gauge_color if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then - local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); - local empty=$(($gauge_slots - $filled)); + filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 )); + empty=$(( $gauge_slots - $filled )); - if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; - elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; - else local gauge_color=$color_red; + if [[ $filled -gt $green_threshold ]]; then + gauge_color=$color_green; + elif [[ $filled -gt $yellow_threshold ]]; then + gauge_color=$color_yellow; + else + gauge_color=$color_red; fi else - local filled=$gauge_slots; - local empty=0; + filled=$gauge_slots; + empty=0; filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; fi - local charging=' ' && battery_is_charging && charging=$charging_symbol; + local charging=' ' + battery_is_charging && charging=$charging_symbol; + # Charging status and prefix printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} - printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} + # Filled slots + [[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} + # Empty slots [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} + # Suffix printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} } -- cgit v1.2.3-70-g09d2 From 39e61614f206f6a552f53c8d1a8b956d8c9ab32f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 13:49:04 +0100 Subject: Clean up Linux battery commands and syntax --- plugins/battery/battery.plugin.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 5322dd18a..c1037ad26 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -116,17 +116,17 @@ elif [[ "$OSTYPE" = freebsd* ]] ; then elif [[ "$OSTYPE" = linux* ]] ; then function battery_is_charging() { - ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] + ! acpi 2>/dev/null | command grep -q '^Battery.*Discharging' } function battery_pct() { if (( $+commands[acpi] )) ; then - echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" + acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]' fi } function battery_pct_remaining() { - if [ ! $(battery_is_charging) ] ; then + if ! battery_is_charging; then battery_pct else echo "External Power" @@ -134,15 +134,17 @@ elif [[ "$OSTYPE" = linux* ]] ; then } function battery_time_remaining() { - if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - echo $(acpi 2>/dev/null | cut -f3 -d ',') + if ! battery_is_charging; then + acpi 2>/dev/null | cut -f3 -d ',' fi } function battery_pct_prompt() { - b=$(battery_pct_remaining) - if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - if [ $b -gt 50 ] ; then + local b=$(battery_pct_remaining) + if battery_is_charging; then + echo "∞" + else + if [[ $b -gt 50 ]]; then color='green' elif [ $b -gt 20 ] ; then color='yellow' @@ -150,8 +152,6 @@ elif [[ "$OSTYPE" = linux* ]] ; then color='red' fi echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" - else - echo "∞" fi } -- cgit v1.2.3-70-g09d2 From 5f6f7b6e8de8e6b64f07deb6b185535a8cdbe03e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Feb 2020 14:17:46 +0100 Subject: Various syntax fixes and function naming equivalence - Fix code style - Fix local definitions - Don't declare unnecessary variables - Use `command` before grep --- plugins/battery/battery.plugin.zsh | 136 +++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 72 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index c1037ad26..7c5bf6f82 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -11,22 +11,21 @@ # Modified to add support for FreeBSD # ########################################### -if [[ "$OSTYPE" = darwin* ]] ; then +if [[ "$OSTYPE" = darwin* ]]; then - function battery_pct() { - local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" - typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') - typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') - integer i=$(((currentcapacity/maxcapacity) * 100)) - echo $i + function battery_is_charging() { + ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes' } - function plugged_in() { - [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] + function battery_pct() { + local smart_battery_status="$(ioreg -rc AppleSmartBattery)" + local -F maxcapacity=$(command grep '^.*"MaxCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*"MaxCapacity"\ =\ //') + local -F currentcapacity=$(command grep '^.*"CurrentCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*CurrentCapacity"\ =\ //') + echo $(( (currentcapacity/maxcapacity) * 100 )) } function battery_pct_remaining() { - if plugged_in ; then + if battery_is_charging; then echo "External Power" else battery_pct @@ -35,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then function battery_time_remaining() { local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" - if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') - if [ $timeremaining -gt 720 ] ; then + if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then + timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') + if [ $timeremaining -gt 720 ]; then echo "::" else echo "~$((timeremaining / 60)):$((timeremaining % 60))" @@ -48,11 +47,11 @@ if [[ "$OSTYPE" = darwin* ]] ; then } function battery_pct_prompt () { - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then b=$(battery_pct_remaining) - if [ $b -gt 50 ] ; then + if [[ $b -gt 50 ]]; then color='green' - elif [ $b -gt 20 ] ; then + elif [[ $b -gt 20 ]]; then color='yellow' else color='red' @@ -63,24 +62,20 @@ if [[ "$OSTYPE" = darwin* ]] ; then fi } - function battery_is_charging() { - [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] - } - -elif [[ "$OSTYPE" = freebsd* ]] ; then +elif [[ "$OSTYPE" = freebsd* ]]; then function battery_is_charging() { [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]] } function battery_pct() { - if (( $+commands[sysctl] )) ; then - echo "$(sysctl -n hw.acpi.battery.life)" + if (( $+commands[sysctl] )); then + sysctl -n hw.acpi.battery.life fi } function battery_pct_remaining() { - if [ ! $(battery_is_charging) ] ; then + if ! battery_is_charging; then battery_pct else echo "External Power" @@ -88,39 +83,40 @@ elif [[ "$OSTYPE" = freebsd* ]] ; then } function battery_time_remaining() { + local remaining_time remaining_time=$(sysctl -n hw.acpi.battery.time) - if [[ $remaining_time -ge 0 ]] ; then - # calculation from https://www.unix.com/shell-programming-and-scripting/23695-convert-minutes-hours-minutes-seconds.html - ((hour=$remaining_time/60)) - ((minute=$remaining_time-$hour*60)) - echo $hour:$minute + if [[ $remaining_time -ge 0 ]]; then + ((hour = $remaining_time / 60 )) + ((minute = $remaining_time % 60 )) + printf %02d:%02d $hour $minute fi } function battery_pct_prompt() { + local b color b=$(battery_pct_remaining) - if [ ! $(battery_is_charging) ] ; then - if [ $b -gt 50 ] ; then + if battery_is_charging; then + echo "∞" + else + if [[ $b -gt 50 ]]; then color='green' - elif [ $b -gt 20 ] ; then + elif [[ $b -gt 20 ]]; then color='yellow' else color='red' fi echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" - else - echo "∞" fi } -elif [[ "$OSTYPE" = linux* ]] ; then +elif [[ "$OSTYPE" = linux* ]]; then function battery_is_charging() { ! acpi 2>/dev/null | command grep -q '^Battery.*Discharging' } function battery_pct() { - if (( $+commands[acpi] )) ; then + if (( $+commands[acpi] )); then acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]' fi } @@ -140,13 +136,14 @@ elif [[ "$OSTYPE" = linux* ]] ; then } function battery_pct_prompt() { - local b=$(battery_pct_remaining) + local b color + b=$(battery_pct_remaining) if battery_is_charging; then echo "∞" else if [[ $b -gt 50 ]]; then color='green' - elif [ $b -gt 20 ] ; then + elif [[ $b -gt 20 ]]; then color='yellow' else color='red' @@ -157,53 +154,50 @@ elif [[ "$OSTYPE" = linux* ]] ; then else # Empty functions so we don't cause errors in prompts - function battery_pct_remaining() { - } - - function battery_time_remaining() { - } - - function battery_pct_prompt() { - } + function battery_is_charging { false } + function battery_pct \ + battery_pct_remaining \ + battery_time_remaining \ + battery_pct_prompt { } fi function battery_level_gauge() { - local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; - local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}; - local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}; - local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; - local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; - local color_red=${BATTERY_COLOR_RED:-%F{red}}; - local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; - local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; - local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; - local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; - local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; - local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; - local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; - - local battery_remaining_percentage=$(battery_pct); + local gauge_slots=${BATTERY_GAUGE_SLOTS:-10} + local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))} + local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))} + local color_green=${BATTERY_COLOR_GREEN:-%F{green}} + local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}} + local color_red=${BATTERY_COLOR_RED:-%F{red}} + local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}} + local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['} + local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'} + local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'} + local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'} + local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow} + local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'} + + local battery_remaining_percentage=$(battery_pct) local filled empty gauge_color if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then - filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 )); - empty=$(( $gauge_slots - $filled )); + filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 )) + empty=$(( $gauge_slots - $filled )) if [[ $filled -gt $green_threshold ]]; then - gauge_color=$color_green; + gauge_color=$color_green elif [[ $filled -gt $yellow_threshold ]]; then - gauge_color=$color_yellow; + gauge_color=$color_yellow else - gauge_color=$color_red; + gauge_color=$color_red fi else - filled=$gauge_slots; - empty=0; - filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; + filled=$gauge_slots + empty=0 + filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'} fi local charging=' ' - battery_is_charging && charging=$charging_symbol; + battery_is_charging && charging=$charging_symbol # Charging status and prefix printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} @@ -214,5 +208,3 @@ function battery_level_gauge() { # Suffix printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} } - - -- cgit v1.2.3-70-g09d2 From b8b87629157b30fc00d0b4af62dd0cf422896346 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 24 Dec 2015 04:11:22 +0200 Subject: Report only active battery (#4726) On a system with multiple batteries (like thinkpads) report percentage and time remaining only for the active battery (the one being discharged). Ideally we should report all batteries, but acpi only shows time remaining for the active battery. Also callers of these functions expect a single return value. This is still better than reporting 596% remaining (like it did on my laptop). For the reference, the output of acpi command with multiple batteries looks like this: Battery 0: Unknown, 5% Battery 1: Discharging, 86%, 03:14:04 remaining --- plugins/battery/battery.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 7c5bf6f82..d1adcd0b6 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -117,7 +117,7 @@ elif [[ "$OSTYPE" = linux* ]]; then function battery_pct() { if (( $+commands[acpi] )); then - acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]' + acpi 2>/dev/null | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]' fi } -- cgit v1.2.3-70-g09d2 From 15a03744a9e87b8dd371a4fbac456a73d27d32d5 Mon Sep 17 00:00:00 2001 From: GregoireW Date: Thu, 17 Oct 2019 11:30:24 +0200 Subject: Remove invalid batteries (#8275) --- plugins/battery/battery.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index d1adcd0b6..6fe801c9f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -112,12 +112,12 @@ elif [[ "$OSTYPE" = freebsd* ]]; then elif [[ "$OSTYPE" = linux* ]]; then function battery_is_charging() { - ! acpi 2>/dev/null | command grep -q '^Battery.*Discharging' + ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging' } function battery_pct() { if (( $+commands[acpi] )); then - acpi 2>/dev/null | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]' + acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]' fi } @@ -131,7 +131,7 @@ elif [[ "$OSTYPE" = linux* ]]; then function battery_time_remaining() { if ! battery_is_charging; then - acpi 2>/dev/null | cut -f3 -d ',' + acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ',' fi } -- cgit v1.2.3-70-g09d2 From e178ae39b41e554722c205d107a664dced1761b9 Mon Sep 17 00:00:00 2001 From: Mazin Ahmed Date: Wed, 12 Feb 2020 20:51:40 +0400 Subject: dotenv: prompt before executing dotenv file (#8606) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/dotenv/dotenv.plugin.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 89763d0ee..d4a6db8f8 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,5 +1,12 @@ source_env() { if [[ -f $ZSH_DOTENV_FILE ]]; then + # confirm before sourcing .env file + local confirmation + echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) " + if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then + return + fi + # test .env syntax zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 -- cgit v1.2.3-70-g09d2 From 3ec04997ebc413ddc95b7c11743b525d7fc7c4ab Mon Sep 17 00:00:00 2001 From: Henry Chang Date: Sun, 26 Mar 2017 18:29:36 -0700 Subject: Add zsh-interactive-cd plugin --- plugins/zsh-interactive-cd/README.md | 23 ++++ .../zsh-interactive-cd.plugin.zsh | 147 +++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 plugins/zsh-interactive-cd/README.md create mode 100644 plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh diff --git a/plugins/zsh-interactive-cd/README.md b/plugins/zsh-interactive-cd/README.md new file mode 100644 index 000000000..c8337fbc8 --- /dev/null +++ b/plugins/zsh-interactive-cd/README.md @@ -0,0 +1,23 @@ +# zsh-interactive-cd + +This plugin adds a fish-like interactive tab completion for the `cd` command. + +To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file: +```zsh +plugins=(... zsh-interactive-cd) +``` + +![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif) + +## Usage + +Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage. + +## Requirements + +This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following +its [installation instructions](https://github.com/junegunn/fzf#installation). + +## Author + +[Henry Chang](https://github.com/changyuheng) diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh new file mode 100644 index 000000000..0f15aeef0 --- /dev/null +++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh @@ -0,0 +1,147 @@ +# Copyright (c) 2017 Henry Chang + +__zic_fzf_prog() { + [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \ + && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" +} + +__zic_matched_subdir_list() { + local dir length seg starts_with_dir + if [[ "$1" == */ ]]; then + dir="$1" + if [[ "$dir" != / ]]; then + dir="${dir: : -1}" + fi + length=$(echo -n "$dir" | wc -c) + if [ "$dir" = "/" ]; then + length=0 + fi + find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \ + | cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do + if [[ "${line[1]}" == "." ]]; then + continue + fi + echo "$line" + done + else + dir=$(dirname -- "$1") + length=$(echo -n "$dir" | wc -c) + if [ "$dir" = "/" ]; then + length=0 + fi + seg=$(basename -- "$1") + starts_with_dir=$( \ + find -L "$dir" -mindepth 1 -maxdepth 1 -type d \ + 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \ + | while read -r line; do + if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then + continue + fi + if [[ "$line" == "$seg"* ]]; then + echo "$line" + fi + done + ) + if [ -n "$starts_with_dir" ]; then + echo "$starts_with_dir" + else + find -L "$dir" -mindepth 1 -maxdepth 1 -type d \ + 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \ + | while read -r line; do + if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then + continue + fi + if [[ "$line" == *"$seg"* ]]; then + echo "$line" + fi + done + fi + fi +} + +_zic_list_generator() { + __zic_matched_subdir_list "${(Q)@[-1]}" | sort +} + +_zic_complete() { + setopt localoptions nonomatch + local l matches fzf tokens base + + l=$(_zic_list_generator $@) + + if [ -z "$l" ]; then + zle ${__zic_default_completion:-expand-or-complete} + return + fi + + fzf=$(__zic_fzf_prog) + + if [ $(echo $l | wc -l) -eq 1 ]; then + matches=${(q)l} + else + matches=$(echo $l \ + | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \ + --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \ + --bind 'shift-tab:up,tab:down'" ${=fzf} \ + | while read -r item; do + echo -n "${(q)item} " + done) + fi + + matches=${matches% } + if [ -n "$matches" ]; then + tokens=(${(z)LBUFFER}) + base="${(Q)@[-1]}" + if [[ "$base" != */ ]]; then + if [[ "$base" == */* ]]; then + base="$(dirname -- "$base")" + if [[ ${base[-1]} != / ]]; then + base="$base/" + fi + else + base="" + fi + fi + LBUFFER="${tokens[1]} " + if [ -n "$base" ]; then + base="${(q)base}" + if [ "${tokens[2][1]}" = "~" ]; then + base="${base/#$HOME/~}" + fi + LBUFFER="${LBUFFER}${base}" + fi + LBUFFER="${LBUFFER}${matches}/" + fi + zle redisplay + typeset -f zle-line-init >/dev/null && zle zle-line-init +} + +zic-completion() { + setopt localoptions noshwordsplit noksh_arrays noposixbuiltins + local tokens cmd + + tokens=(${(z)LBUFFER}) + cmd=${tokens[1]} + + if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then + zle ${__zic_default_completion:-expand-or-complete} + elif [ "$cmd" = cd ]; then + _zic_complete ${tokens[2,${#tokens}]/#\~/$HOME} + else + zle ${__zic_default_completion:-expand-or-complete} + fi +} + +[ -z "$__zic_default_completion" ] && { + binding=$(bindkey '^I') + # $binding[(s: :w)2] + # The command substitution and following word splitting to determine the + # default zle widget for ^I formerly only works if the IFS parameter contains + # a space via $binding[(w)2]. Now it specifically splits at spaces, regardless + # of IFS. + [[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2] + unset binding +} + +zle -N zic-completion +bindkey '^I' zic-completion -- cgit v1.2.3-70-g09d2 From a6df94d2c677c6d28c5ee339975b7a56a2f67e21 Mon Sep 17 00:00:00 2001 From: Jonatan Ivanov Date: Wed, 12 Feb 2020 12:52:47 -0800 Subject: gradle: run gradle command instead of alias (#8620) - Similarly to the mvn plugin - Without this fix, the shell crashes in some cases --- plugins/gradle/gradle.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 6be583179..c651b91ca 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -7,7 +7,7 @@ gradle-or-gradlew() { echo "executing gradlew instead of gradle"; ./gradlew "$@"; else - gradle "$@"; + command gradle "$@"; fi } -- cgit v1.2.3-70-g09d2