Created
October 2, 2012 15:09
-
-
Save pyro2927/3819936 to your computer and use it in GitHub Desktop.
Screen stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in ~/.screenrc | |
# see http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html | |
# support color X terminals | |
termcap  xterm 'XT:AF=\E[3%dm:AB=\E[4%dm:AX' | |
terminfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX' | |
termcapinfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' | |
termcap  xtermc 'XT:AF=\E[3%dm:AB=\E[4%dm:AX' | |
terminfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX' | |
termcapinfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' | |
# auto-screen support; see http://taint.org/wk/RemoteLoginAutoScreen | |
# detach on hangup | |
autodetach on | |
# no startup msg | |
startup_message off | |
# always use a login shell | |
shell -$SHELL | |
# allow mutli-user | |
multiuser on | |
# auto-log | |
logfile $HOME/screenlogs/%Y%m%d-%n.log | |
deflog on | |
#allow mouse scrolling (works in OSX) | |
termcapinfo xterm* ti@:te@ dw | |
defscrollback 5000 | |
caption string "%?%F%{= Bk}%? %C%A %D %d-%m-%Y %{= kB} %t%= %?%F%{= Bk}%:%{= wk}%? %n " | |
hardstatus alwayslastline | |
backtick 1 60 60 $HOME/.screen_hardstatus ip | |
backtick 2 60 60 $HOME/.screen_hardstatus mem | |
backtick 3 5 5 $HOME/.screen_hardstatus disk | |
backtick 4 5 5 $HOME/.screen_hardstatus proc | |
hardstatus string '%{= kG}[%{G}%H %1`%{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][ %{G}%l %2`%{g}]%{r}%3`%4`%{r}%{w}[ %{B}%m/%d %c %{w}]' | |
# put this in ~/.screen_hardstatus and chmod +x it | |
#!/bin/bash | |
# Script to get run by hardstatus in screen. | |
# Prints customized single-line system stats | |
DISKPERCENT=80 | |
PROCPERCENT=0 | |
if [ $1 == "ip" ]; then | |
{ | |
    IP=`ifconfig | grep 255.255 | cut -d: -f2 | cut -d " " -f1` | |
    echo -n "$IP" | |
} | |
fi | |
if [ $1 == "mem" ]; then | |
    echo -n `free -m | grep Mem: | awk '{print ($4 * 100/$2)}' | sed -e 's,\.[0-9]*,%,g'` | |
fi | |
if [ $1 == "disk" ]; then | |
    df -l | sed -e '1d' | grep -v none | awk -v DISKPERCENT=$DISKPERCENT '{if (($3 * 100/($3+$4)) > $DISKPERCENT) print "[" $1 " " ($3 * 100/($3+$4)) }' | sed -e 's,\.[0-9]*,%],g' | |
fi | |
if [ $1 == "proc" ]; then | |
    ps aux | sort -r -k3,3 | sed -n '2p' | awk '{if ($3 >  "'"$PROCPERCENT"'") print "["$2" "$11" "$3"%]"}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment