Skip to main content

Battery

What​

caution

The segment is not supported and automatically disabled on Windows when WSL 1 is detected. Works fine with WSL 2.

Battery displays the remaining power percentage for your battery.

Sample Configuration​

− ▢ × 70 _ ohmyposh.dev − ▢ × 70 _ ohmyposh.dev

Options​

NameTypeDefaultDescription
display_errorbooleanfalseshow the error context when failing to retrieve the battery information
charging_iconstringicon to display when charging
discharging_iconstringicon to display when discharging
charged_iconstringicon to display when fully charged
not_charging_iconstringicon to display when on AC power

Template (info)​

default template
{{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}

Properties​

NameTypeDescription
.Statestructthe battery state, has a .String function
.Percentagefloat64the current battery percentage
.Errorstringthe error in case fetching the battery information failed
.Iconstringthe icon based on the battery state