Fix battery plugin when acpi writes to stderr (#5413)
* Fix battery plugin when acpi writes to stderr
* Make stderr redirection in battery plugin more idiomatic
Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index 014bb15dd0ce0c79be54012a9a5add21c45433b1..0bb9e77f09174d8b08da465229157089dc00962b 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -67,12 +67,12 @@ if [[ "$OSTYPE" = darwin* ]] ; then
6 elif [[ $(uname) == "Linux" ]] ; then
7 8 function battery_is_charging() {
9- ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
10+ ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
11 }
1213 function battery_pct() {
14 if (( $+commands[acpi] )) ; then
15- echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
16+ echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
17 fi
18 }
1920@@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then
21 }
2223 function battery_time_remaining() {
24- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
25- echo $(acpi | cut -f3 -d ',')
26+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
27+ echo $(acpi 2>/dev/null | cut -f3 -d ',')
28 fi
29 }
3031 function battery_pct_prompt() {
32 b=$(battery_pct_remaining)
33- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
34+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
35 if [ $b -gt 50 ] ; then
36 color='green'
37 elif [ $b -gt 20 ] ; then