Skip to content

Instantly share code, notes, and snippets.

@trobrock
Last active December 14, 2015 04:59
Show Gist options
  • Save trobrock/5032043 to your computer and use it in GitHub Desktop.
Save trobrock/5032043 to your computer and use it in GitHub Desktop.
#!/bin/zsh
cpu=$(top -l 1 | awk '/CPU usage/{ print $3 }')
percent=$(echo $cpu | awk '{ print $1+0 }' | xargs -I'{}' ruby -e "print {}.to_i")
color="default"
if [ "$percent" -gt 90 ]; then
color="red"
elif [ "$percent" -gt 75 ]; then
color="yellow"
fi
output=""
if [[ $color == "default" ]]; then
output="#[default]"
else
output="#[fg=$color]"
fi
output="$output$percent%#[default]"
echo $output
#!/bin/zsh
echo $(uptime | awk -F'load averages:' '{ print $2 }' | awk '{ print $2 }')
#!/bin/zsh
memory=$(top -l 1 | awk /PhysMem/)
free=$(echo $memory | awk '{ print $10+0 }')
used=$(echo $memory | awk '{ print $8+0 }')
total=$(echo $memory | awk '{ print $8+$10 }')
percent=$(ruby -e "print (($used.to_f/$total.to_f) * 100).to_i")
color="default"
if [ "$percent" -gt 90 ]; then
color="red"
elif [ "$percent" -gt 75 ]; then
color="yellow"
fi
output=""
if [[ $color == "default" ]]; then
output="#[default]"
else
output="#[fg=$color]"
fi
output="$output$percent%#[default]"
echo $output
#!/bin/zsh
power=$(/usr/sbin/ioreg -l | awk 'BEGIN{a=0;b=0}
$0 ~ "MaxCapacity" {a=$5;next}
$0 ~ "CurrentCapacity" {b=$5;nextfile}
END{printf("%.2f%%", b/a * 100)}')
charging=$(/usr/sbin/ioreg -l | awk '/IsCharging/{ print $5 }')
power_int=$(echo $power | sed 's/\..*//')
output=""
if [ $power_int -gt 75 ]
then
output="$output#[default]"
elif [ $power_int -lt 20 ]
then
output="$output#[fg=red]"
else
output="$output#[fg=yellow]"
fi
if [ $charging = "Yes" ]
then
output="#[default]⟲ $output"
fi
echo "$output$power"
set -g default-terminal "screen-256color"
# Use the system pasteboard
set-option -g default-command "reattach-to-user-namespace -l zsh"
# Bind Control key to match Screen
set -g prefix C-a
# Use vi key bindings
set -g status-keys vi
setw -g mode-keys vi
# Control+C-a to go to previous window
bind-key C-a last-window
# Status bar options
set -g status-fg green
set -g status-bg black
set -g status-left-length 60
set -g status-left "[ #S l:#(/Users/trobrock/Scripts/load.sh) m:#(/Users/trobrock/Scripts/memory.sh) chefvm:#[fg=blue]#(chefvm current)#[fg=default] ] ["
set -g status-right ' ] [ #(/Users/trobrock/Scripts/power.sh) #[fg=blue]%Y-%m-%d #[fg=default]%H:%M ]'
# Window title Options
set-window-option -g window-status-fg white
set-window-option -g window-status-bg black
set-window-option -g window-status-attr dim
# active window title colors
set -g window-status-format '#I:#W#F'
set -g window-status-current-format '#[bg=colour245,fg=black]#I:#W '
set-window-option -g mode-fg white
set-window-option -g mode-bg red
set-window-option -g mode-attr bright
# Remap split window keys
unbind % # Remove default binding since we’re replacing
bind | split-window -h
bind - split-window -v
# Resize to the smallest client actively viewing a window
setw -g aggressive-resize on
# Don't wait so long for commands
set -s escape-time 0
# Resize current nd-key k select-pane -U
bind-key j resize-pane -D 20
bind-key h resize-pane -L 20
bind-key l resize-pane -R 20
bind-key k resize-pane -U 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment