Created
January 24, 2022 23:26
-
-
Save nicolasdanelon/a1bf313b3ab39790cee48af551d0f8d2 to your computer and use it in GitHub Desktop.
script not working on .zshrc file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myMacStatus() | |
system_profiler_cache=$(system_profiler SPPowerDataType) | |
battery_cicles=$(echo $system_profiler_cache | grep 'Cycle Count' | awk '{print $3}') | |
battery_charge=$(echo $system_profiler_cache | grep 'State of Charge' | awk '{print $5}') | |
battery_condition=$(echo $system_profiler_cache | grep 'Condition' | awk '{print $2}') | |
echo "\n" | |
# echo "Life used by SSD: $(smartctl -a disk0 | grep 'Percentage Used' | awk '{print $3}')" | |
echo Battery cycles: $battery_cicles | |
echo Battery charge: $battery_charge% | |
echo Battery condition: $battery_condition | |
echo "\n" | |
myMacStatus() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "\n" | |
echo Battery cycles: $(system_profiler SPPowerDataType | grep 'Cycle Count' | awk '{print $3}') | |
echo Battery charge: $(system_profiler SPPowerDataType | grep 'State of Charge' | awk '{print $5}')% | |
echo Battery condition: $(system_profiler SPPowerDataType | grep 'Condition' | awk '{print $2}') | |
echo "\n" | |
# zsh /tmp/old.bash | |
# | |
# 0.18s user | |
# 0.33s system | |
# 80% cpu | |
# 0.634 total |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system_profiler_cache=$(system_profiler SPPowerDataType) | |
battery_cicles=$(echo $(echo $system_profiler_cache | grep 'Cycle Count' | awk '{print $3}')) | |
battery_charge=$(echo $(echo $system_profiler_cache | grep 'State of Charge' | awk '{print $5}')) | |
battery_condition=$(echo $(echo $system_profiler_cache | grep 'Condition' | awk '{print $2}')) | |
echo "\n" | |
echo Battery cycles: $battery_cicles | |
echo Battery charge: $battery_charge% | |
echo Battery condition: $battery_condition | |
echo "\n" | |
# zsh /tmp/op.bash | |
# 0.07s user | |
# 0.13s system | |
# 70% cpu | |
# 0.281 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment