2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env sh
|
2024-03-26 15:08:14 -07:00
|
|
|
# YES_ZSH YES_BASH YES_DASH YES_ASH YES_BB_AWK
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-07-30 19:41:16 -07:00
|
|
|
psbm() { ### @-
|
2021-08-01 09:27:25 -07:00
|
|
|
### display and order processes by their memory usage ascending, and their sum.
|
|
|
|
###
|
|
|
|
### ```
|
|
|
|
### $ psbm | head -n -1 | tail -2
|
|
|
|
### 185.08M 1163 chromium
|
|
|
|
### 199.95M 1060 chromium
|
|
|
|
### ```
|
2021-07-29 05:44:12 -07:00
|
|
|
[ -z "$MSYSTEM" ] || { printf "%s\n" "$0: unsupported on MSYS2" >&2; return 1; }
|
2021-07-29 00:37:35 -07:00
|
|
|
ps axco rss,pid,command | awk '
|
|
|
|
NR>1&&$1>0{t+=$1;printf("%8.2fM %7d %s\n",$1/1024,$2,$3)}
|
|
|
|
END{printf("%8.2fM\n",t/1024)}
|
|
|
|
' | sort -n
|
|
|
|
}
|
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || psbm "$@"
|