Skip to content

Instantly share code, notes, and snippets.

View LeslieZhu's full-sized avatar
🏠
Working from home

LeslieZhu LeslieZhu

🏠
Working from home
View GitHub Profile
full=$(pmset -g batt | { read; read n full; echo "$full"; })
batt=$(echo "$full" | cut -d';' -f1 | tr -d '%')
status=$(echo "$full" | cut -d';' -f2 | tr -d ' ')
time=$(echo "$full" | cut -d';' -f3 | sed 's/^ *//')
noc=$'\e[39m'
if (($batt >= 66)); then battc=$'\e[32m';
elif (($batt >= 33)); then battc=$'\e[33m';
else battc=$'\e[31m';
fi;
ps xro %cpu=,comm= | while read cpu comm; ((i++<5)); do
int=$cpu
int="${int%%.*}"
if (($int >= 50)); then color=$'\e[31m';
elif (($int >= 25)); then color=$'\e[33m';
else color=$'\e[32m';
fi;
echo "$color$cpu% $(basename "$comm")"$'\e[0m'"";
@SamRothCA
SamRothCA / storageusage.sh
Last active January 23, 2021 19:36
Storage volume usage
df -Hl | {
read keys;
keys="${keys%% on}";
while read ${keys//%}; do
echo "`basename "$Mounted"` - $Used/$Size ($Capacity)";
done
}
@SamRothCA
SamRothCA / memoryusage.sh
Created October 30, 2014 20:38
Memory Usage
ps xmo rss=,pmem=,comm= | while read rss pmem comm; ((n++<5)); do
size="$[rss/1024]";
short=$[4-${#size}];
size="(${size}M)";
i=0;
while ((i++ < short)); do size=" $size"; done;
pmem="${pmem%%.*}"
if (($pmem >= 20)); then color=$'\e[31m';
@JerryFleming
JerryFleming / wallpapers.sh
Last active December 17, 2015 01:48
Update your wallpapers regularly (please don't be frequently) by polling wallpaperswide.com.
#!/bin/bash
# Update your wallpapager regularly.
# Preferrably installing it in your crontab:
#
# (crontab -l | sed '1,3d'; echo "# Update wallpager every half an hour."; echo "0,30 * * * * /path/to/wallpaper.sh") | crontab -
#
# by Jerry Fleming <[email protected]>
# on 2013-03-25.
# No rights reserved. Use at your own risk.
@bvsatyaram
bvsatyaram / .gitconfig
Created December 20, 2011 05:10 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]