Skip to content

Commit

Permalink
tmux status line
Browse files Browse the repository at this point in the history
  • Loading branch information
creaktive committed Nov 29, 2012
1 parent 7740296 commit e5b7184
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
6 changes: 2 additions & 4 deletions .tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ bind - split-window -v
set -g status-bg black
set -g status-fg white
set -g status-left '#[fg=green]#H'
set -g status-right '#[fg=yellow]#(cut -d " " -f1-4 /proc/loadavg)'
#set -g status-right '#[fg=yellow]#(macbook-stats.pl)'
#set -g status-right '#[fg=yellow]#(uptime|cut -d " " -f10-)'
set -g status-right '#[fg=yellow]#(macbook-stats.pl)'
set -g status-interval 60
set -g status-right-length 60
set -g status-right-length 64

# Highlight active window
set-window-option -g window-status-current-bg red
Expand Down
51 changes: 49 additions & 2 deletions bin/macbook-stats.pl
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
#!/usr/bin/env perl
%m=map{/Pages (free|active|inactive|wired down):\s*(\d+)/;(substr($1,0,1)=>$2<<12)}qx{vm_stat};delete$m{q{}};@l=split/\s+/,qx{uptime};@b=map{(/(\d+)$/)[0]}grep{/(Max|Current)Capacity/}qx{ioreg -l};printf qq{%s l:%s/%s/%s b:%.01f%%\n},(join q{ },map{sprintf q(%s:%0.2fG),$_,$m{$_}/(2**30)}sort keys%m),@l[-3..-1],100*$b[1]/$b[0]
#!/usr/bin/perl
use strict;
use warnings;

my %memory;
if (-x q{/usr/bin/vm_stat}) {
%memory = map {
/\bPages\s+(free|active|inactive|wired\s+down):\s*(\d+)/ix
? (substr($1, 0, 1) => $2 << 2)
: ();
} qx{vm_stat};
} elsif (open my $meminfo, q{<}, q{/proc/meminfo}) {
%memory = map {
/\b(?:Mem)?(Free|Cached|Active|Inactive):\s*(\d+)/ix
? (substr($1, 0, 1) => $2)
: ();
} <$meminfo>;
close $meminfo;
}

%memory && print
map {
sprintf q( %s:%0.2fG),
lc,
$memory{$_} / (2 ** 20)
} sort keys %memory;

my @load;
if (open my $loadavg, q{<}, q{/proc/loadavg}) {
@load = (split /\s+/x, <$loadavg>)[0 .. 2];
close $loadavg;
} elsif (-x q{/usr/bin/uptime}) {
@load = (split /\s+/x, qx{uptime})[-3 .. -1];
}

@load && print q{ l:}, join q{/}, @load;

if (-x q{/usr/sbin/ioreg}) {
my @battery = map {
/"(?:(?:Max|Current)Capacity|ExternalConnected)"\s*=\s*(\d+|Yes|No)/ix
? $1
: ()
} qx{ioreg -n AppleSmartBattery -r};
printf q{ b:%s%.01f%%},
$battery[2] =~ /^y/ix ? q{} : q{!},
100 * $battery[1] / $battery[0];
}

printf qq{ %02d:%02d\n}, (localtime)[2, 1];

0 comments on commit e5b7184

Please sign in to comment.