1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2025-12-12 15:34:50 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Marc Cornellà
d959283898 avit: fix prompt sequence (fixes #8678) 2020-02-25 12:21:06 +01:00
Yahav Itzhak
b72607bc8e
Add JFrog CLI plugin (#8250) 2020-02-25 12:00:25 +01:00
Marc Cornellà
7290a08bf6 battery: fix floating point output in macOS
Fixes #8676
2020-02-25 11:56:26 +01:00
4 changed files with 40 additions and 17 deletions

View File

@ -21,7 +21,8 @@ if [[ "$OSTYPE" = darwin* ]]; then
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 ))
local -i pct=$(( (currentcapacity/maxcapacity) * 100 ))
echo $pct
}
function battery_pct_remaining() {
@ -47,16 +48,17 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
function battery_pct_prompt () {
local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
b=$(battery_pct_remaining)
if [[ $b -gt 50 ]]; then
battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $b -gt 20 ]]; then
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else
echo "∞"
fi
@ -93,19 +95,19 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
}
function battery_pct_prompt() {
local b color
b=$(battery_pct_remaining)
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $b -gt 50 ]]; then
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $b -gt 20 ]]; then
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
@ -136,19 +138,19 @@ elif [[ "$OSTYPE" = linux* ]]; then
}
function battery_pct_prompt() {
local b color
b=$(battery_pct_remaining)
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $b -gt 50 ]]; then
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $b -gt 20 ]]; then
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}

11
plugins/jfrog/README.md Normal file
View File

@ -0,0 +1,11 @@
# JFrog CLI
This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli).
JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs.
To use it, add `jfrog` to the plugins array in your zshrc file:
```zsh
plugins=(... jfrog)
```

View File

@ -0,0 +1,10 @@
_jfrog() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then
_files
fi
}
compdef _jfrog jfrog

View File

@ -7,9 +7,9 @@ typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
%{%F{%(!.red.white)}%}▶%{$resetcolor%} '
%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} '
PROMPT2='%{%F{%(!.red.white)}%}◀%{$reset_color%} '
PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'