# Requires `inxi` package to be installed function fish_right_prompt -d "Write out the right prompt" # Get battery percentage and status set level (inxi --battery | python -c "import sys, re; input = sys.stdin.read(); line = input.split()[6]; print(re.sub('[()]', '', line))") set battery_status (upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state:" | awk '{ print $2 }') # Define colors # Normal colors # black, red, green, yellow, blue, magenta, cyan, white # Bright colors # brblack, brred, brgreen, bryellow, brblue, brmagenta, brcyan, brwhite set color_normal white set color_charging yellow set color_discharging red set color_fully_charged green # Determine color based on charging state switch $battery_status case "charging" set color $color_charging set icon 🔌 case "discharging" set color $color_discharging set icon 🔋 case "fully-charged" set color $color_fully_charged set icon ✅ case "*" set color $color_normal set icon ❔ end # Display battery percentage echo -e (set_color $color) "[ $level $icon ]" (set_color normal) end