[issue845] df() shell function
Andras Korn
bts at bts.grml.org
Fri Apr 23 18:27:11 CEST 2010
New submission from Andras Korn <korn-grml at elan.rulez.org>:
Hi,
please consider including this in your zshrc:
function df() {
/bin/df -a --portability "$@" | column -t | sed
's/Mounted[[:space:]]*on/Mounted on/'
}
This makes df output a lot more readable by making sure that all information for
each filesystem is on a single line and still nicely tabulated.
Observe the difference between the old and new behaviour:
Old:
Filesystem Size Used Avail Use% Mounted on
/dev/md0 254M 170M 85M 67% /
tmpfs 3.9G 0 3.9G 0% /lib/init/rw
udev 10M 516K 9.5M 6% /dev
tmpfs 3.9G 2.4M 3.9G 1% /dev/shm
/dev/mapper/unencrypted-tmp
1.1G 164M 951M 15% /tmp
/dev/mapper/unencrypted-usr
1.8G 757M 1.1G 42% /usr
/dev/mapper/unencrypted-var
1014M 162M 853M 16% /var
/dev/mapper/unencrypted-var_log_sv
124M 40M 85M 32% /var/log/sv
/dev/mapper/unencrypted-var_cache_apt
764M 433M 331M 57% /shared/var_cache_apt
/dev/mapper/encrypted-netflow
2.0G 2.0G 67M 97% /var/spool/netflow
New:
Filesystem Size Used Avail Use% Mounted on
/dev/md0 254M 170M 85M 67% /
tmpfs 3.9G 0 3.9G 0% /lib/init/rw
udev 10M 516K 9.5M 6% /dev
tmpfs 3.9G 2.4M 3.9G 1% /dev/shm
/dev/mapper/unencrypted-tmp 1.1G 164M 951M 15% /tmp
/dev/mapper/unencrypted-usr 1.8G 757M 1.1G 42% /usr
/dev/mapper/unencrypted-var 1014M 162M 853M 16% /var
/dev/mapper/unencrypted-var_log_sv 124M 40M 85M 32% /var/log/sv
/dev/mapper/unencrypted-var_cache_apt 764M 433M 331M 57%
/shared/var_cache_apt
/dev/mapper/encrypted-netflow 2.0G 2.0G 67M 97%
/var/spool/netflow
Including the -a (which causes "dummy" filesystems to be included) is useful
especially for chroots and vservers with bind mounted filesystems; if /etc/mtab
includes an entry where the device doesn't exist, df will by default skip that
entry in the output, which is the wrong thing to do for bind mounts. I don't
think there are so many actual dummy filesystems that their inclusion would
seriously clutter the output of df.
Placing this function in zshrc would ensure that it's only loaded for
interactive shells; thus it wouldn't interfere with scripts that attempt to
parse the output of df(1).
----------
messages: 3151
nosy: korn
priority: wish
status: unread
title: df() shell function
topic: zsh
_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue845>
_____________________________________
More information about the Bugs-changes
mailing list