#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/ps-mem preem () { local pid=$1 pmap $pid | awk '/total/{ print $2 }' } freem () { vmstat -s -S M | awk '/free memory/{ print $1" M" }' } most-something () { local most=$1 local number=${2:-10} number=$(( $number + 1 )) watch -n 3 -t "ps -e -o pid,comm,user,%cpu,%mem --sort=-$most | head -n $number" } most-memory () { most-something '%mem' $1 } most-cpu () { most-something '%cpu' $1 }