Skip to content

Instantly share code, notes, and snippets.

@artursapek
Created November 25, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artursapek/cc06685e6bf3968838b082093717038c to your computer and use it in GitHub Desktop.
Save artursapek/cc06685e6bf3968838b082093717038c to your computer and use it in GitHub Desktop.
# for tmux status bar
info = `pmset -g batt`.split("\n")
perc = info[1].split(" ")[1].gsub(";","")
charging = info[0].include? "AC Power"
as_f = perc.to_f
if as_f > 75
status = "green"
bars = 4
elsif as_f > 50
status = "yellow"
bars = 3
elsif as_f > 25
status = "yellow"
bars = 2
else
status = "red"
bars = 1
end
if charging
status = "blue"
end
puts "#[fg=#{status}][#{"|" * bars}#{" " * (4 - bars)}] #{perc}#{charging ? "*":""}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment