Today Scripts 脚本

Posted on Posted in mac
Tips: 本文创建于2015年4月15日,已超过 2 年,内容或图片可能已经失效!
1、公网IP
curl ifconfig.me
?2、电池状态
pmset -g batt | { read; read n status; echo "$status"; }
3、 RAM占用最高5个程序
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';
elif (($pmem >= 10)); then color=$'\e[33m';
else                       color=$'\e[32m ';
fi;

echo "$color$pmem% $size $(basename "$comm")"$'\e[0m'"";
done
4、 CPU占用最高的5个程序
ps xro %cpu=,comm= | while read cpu comm; ((i++<5)); do echo $cpu% $(basename "$comm"); done
?5、硬盘
df -Hl | {
read keys;
keys="${keys%% on}";
while read ${keys//%}; do
   echo "`basename "$Mounted"` – $Used/$Size ($Capacity)";
done
}

 

» 转载请注明来源:若我若鱼 » Today Scripts 脚本

Leave a Reply

Your email address will not be published. Required fields are marked *

8 − two =