Last active
July 14, 2016 14:23
-
-
Save aheadley/6f52f5acefb40535e0a6d2925e1b1bd4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[2016-07-14T10:22:29-0400|aheadley@ag-mdt([email protected]):/home/aheadley]=============== | |
$ | |
[2016-07-14T10:22:42-0400|aheadley@ag-mdt([email protected]):...eadley/devel/marble/marble] | |
$ |
This file contains hidden or 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
_pc () | |
{ | |
local LOAD=$(cut -f1 -d' ' < /proc/loadavg); | |
local iLOAD=${LOAD%%.*}; | |
if [ $iLOAD -lt $(($PROCS * 2)) ]; then | |
local TWIDTH=$(tput cols); | |
local PADDING='='; | |
local TIMESTAMP="$(date '+%Y-%m-%dT%H:%M:%S%z')"; | |
local MEAT="[${TIMESTAMP}|${USER}@${HOSTNAME}(${PROCS}@${LOAD})"; | |
if [ $TWIDTH -ge 80 ]; then | |
if [ $(( ${#MEAT} + ${#PWD} + 2 )) -gt $TWIDTH ]; then | |
MEAT="${MEAT}:...${PWD:$(( ${#PWD} - $(( ${TWIDTH} - $(( ${#MEAT} + 5 )) )) )) }"; | |
else | |
MEAT="${MEAT}:${PWD}"; | |
fi; | |
fi; | |
MEAT="${MEAT}]"; | |
echo -en "${MEAT}"; | |
for i in $(seq $(($TWIDTH - ${#MEAT})) ); | |
do | |
echo -n "${PADDING}"; | |
done; | |
echo -e "\e[00m"; | |
else | |
echo -e "\e[1;31m** HIGH LOAD: ${PROCS}@${LOAD} **\e[00m"; | |
fi | |
} | |
export PROMPT_COMMAND=_pc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment