Last active
July 30, 2019 17:29
-
-
Save aheadley/e5577f0457e97dcee3713cfc18cc77fa 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
function _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 -e '\e[1;37m" #white | |
echo -en "${MEAT}" | |
for i in $(seq $(($TWIDTH - ${#MEAT})) ); do | |
echo -n "${PADDING}" | |
done | |
echo -e "\e[00m" #reset | |
else | |
echo -e "\e[1;31m** HIGH LOAD: ${PROCS}@${LOAD} **\e[00m" | |
fi | |
} | |
export PS1='\$ ' | |
export PROMPT_COMMAND='_pc' |
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
[2019-07-30T13:28:59-0400|[email protected]([email protected]):/home/aheadley]=========================================== | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment