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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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 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(+) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(+) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(+) (limited to 'plugins') 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(-) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(+) (limited to 'plugins') 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 (limited to 'plugins') 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(-) (limited to 'plugins') 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