mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
battery charge (via habrahabr.ru)
This commit is contained in:
parent
8520dad7d7
commit
b268f1515d
1 changed files with 19 additions and 1 deletions
|
|
@ -1,5 +1,23 @@
|
|||
function battery_charge {
|
||||
# Battery 0: Discharging, 94%, 03:46:34 remaining
|
||||
bat_percent=`acpi | awk -F ':' {'print $2;'} | awk -F ',' {'print $2;'} | sed -e "s/\s//" -e "s/%.*//"`
|
||||
|
||||
if [ $bat_percent -lt 20 ]; then cl='%F{red}'
|
||||
elif [ $bat_percent -lt 50 ]; then cl='%F{yellow}'
|
||||
else cl='%F{green}'
|
||||
fi
|
||||
|
||||
filled=${(l:`expr $bat_percent / 10`::▸:)}
|
||||
empty=${(l:`expr 10 - $bat_percent / 10`::▹:)}
|
||||
echo $cl$filled$empty'%F{default}'
|
||||
}
|
||||
|
||||
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
RPROMPT="%T %D"
|
||||
if [ -x /usr/bin/acpi ]; then
|
||||
RPROMPT="%T %D $(battery_charge)"
|
||||
else
|
||||
RPROMPT="%T %D"
|
||||
fi
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue