1
cattyhouse 2022-03-30 14:13:56 +08:00 1
系统自带的 zsh, 举例
alias: alias la="ls -lArth" function: batteryinfo () { local arr remain_battery charge_state cycle health capacity source arr=($(system_profiler -json SPPowerDataType | jq -r '(.SPPowerDataType[0] | (.sppower_battery_charge_info | .sppower_battery_state_of_charge, .sppower_battery_is_charging), (.sppower_battery_health_info | .sppower_battery_cycle_count, .sppower_battery_health, .sppower_battery_health_maximum_capacity)), (.SPPowerDataType[1] | ."AC Power" ."Current Power Source")')) remain_battery="${arr[1]}" charge_state="${arr[2]}" cycle="${arr[3]}" health="${arr[4]}" capacity="${arr[5]}" [[ ${arr[6]} = 'TRUE' ]] && source=外部电源 || source=内部电池 printf "%s\n%s\n%s\n%s\n%s\n%s\n" "剩余电量 : ${ggg} ${remain_battery}% ${nnn}" "是否充电 : ${ggg} $charge_state ${nnn}" "供电系统 : ${ggg} $source ${nnn}" "循环次数 : ${ggg} $cycle ${nnn}" "健康状况 : ${ggg} $health ${nnn}" "健康程度 : ${ggg} $capacity ${nnn}" } |
2
yqf0215 OP ?? 看不懂啊。。。怎么用啊?
|