mirror of
https://github.com/notwa/rc
synced 2024-11-13 22:39:02 -08:00
23 lines
586 B
Bash
Executable file
23 lines
586 B
Bash
Executable file
#!/usr/bin/env sh
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
# YES_ASH
|
|
# YES_BB_AWK
|
|
|
|
psbm() { ### @-
|
|
### 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
|
|
### ```
|
|
[ -z "$MSYSTEM" ] || { printf "%s\n" "$0: unsupported on MSYS2" >&2; return 1; }
|
|
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
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || psbm "$@"
|