Skip to content

Instantly share code, notes, and snippets.

View SamRothCA's full-sized avatar

Sam Rothenberg SamRothCA

  • San Francisco, CA
View GitHub Profile
@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';
@SamRothCA
SamRothCA / temperaturereadings.sh
Created October 30, 2014 20:44
Temperature Readings
/Applications/TemperatureMonitor.app/Contents/MacOS/tempmonitor -a -l -f |
while read reading; do
set -- $reading;
temperature="${@:$[$#-1]:1}";
sensor="${@:2:$[$#-3]}";
sensor="${sensor:0:$[${#sensor}-1]}";
sensor="${sensor//(}";
sensor="${sensor//)}";
@SamRothCA
SamRothCA / cpusuage.sh
Created October 30, 2014 20:46
Display the top five processes by CPU usage
ps xro %cpu=,comm= | while read cpu comm; ((i++<5)); do echo $cpu% $(basename "$comm"); done
@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 / servertest.sh
Created October 30, 2014 20:51
Test if a server is online
ping -c1 -t3 example.com &> /dev/null
@SamRothCA
SamRothCA / batterystatus.sh
Created October 30, 2014 20:52
Battery Status
pmset -g batt | { read; read n status; echo "$status"; }
@SamRothCA
SamRothCA / gitstatus.sh
Created October 30, 2014 20:57
Git Status
cd ~/path/to/repo && git status --short
@SamRothCA
SamRothCA / gitbranchstatus.sh
Created October 30, 2014 20:59
Repo status with branch info
cd ~/path/to/repo && git status --short --branch
@SamRothCA
SamRothCA / gitlastcommit.sh
Created October 30, 2014 21:01
Git Last Commit
cd ~/path/to/repo && git log --abbrev-commit --date=relative -1
@SamRothCA
SamRothCA / gitfinderstats.sh
Last active April 1, 2019 17:59
Git status for repo currently open in Finder
cd "$(osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)')" &&
git status --short --branch