conf-99-basic_config_debian/root/.profile.d/00_functions.conf
Alban VIDAL cd2a8d7ed8 Add some aliases and functions
Signed-off-by: Alban VIDAL <alban.vidal@zordhak.fr>
2018-05-30 01:03:27 +02:00

33 lines
966 B
Plaintext

# Hard Drive usage
function hddtop() {
df -TPh \
| grep -E '(^/dev|^ealf)' \
| sort -k 6,6 -n \
| awk \
-v red="$(tput setaf 1)" \
-v yellow="$(tput setaf 3)" \
-v green="$(tput setaf 2)" \
-v reset="$(tput sgr0)" \
'{printf OFS"%s %s %s %s %s %s %s %s %s\n", \
(+$6>90)?red:(+$6>80?yellow:green),$1,$2,$3,$4,$5,$6,$7,reset \
}' \
| column -t
}
# List all ip's v4
ip4all () {
ip -4 -o addr \
| grep -v 127.0.0 \
| awk -v blue="$(tput bold;tput setaf 4)" -v reset="$(tput sgr0)" '{printf "%s\t%s\t%s %s %s\n",$2,":",blue,$4,reset}'
}
# Show top usage memory
function memtop () {
ps -eo size,pid,user,command --sort -size \
| awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x <=NF ;x++ ) { printf("%s ",$x) } print ""}' \
| cut -d "" -f2 \
| cut -d "-" -f1 \
| head -20
}