all repos — dotfiles @ e1d633237c3b3120d383539cbc5d085eb88b86f5

my *nix dotfiles

home/bin/bat (view raw)

 1#!/usr/bin/env bash
 2
 3if [[ "$(uname)" == "Darwin" ]]; then
 4    cap="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)"
 5    is_charging=""
 6else
 7    cap="$(apm -l)"
 8    is_charging="$(apm -a)"
 9
10    status="discharging"
11fi
12
13tmux_bat() {
14    if [[ "$is_charging" -eq 1 ]]; then 
15        printf '%s%%' "+$cap"
16    else
17        printf '%s%%' "$cap"
18    fi
19}
20
21if [[ "$1" == "-q" ]]; then
22   tmux_bat 
23else
24    [[ "$is_charging" -eq 1 ]] &&
25        status="charging"
26    printf '%s%% [%s]\n' $cap $status 
27fi