utility: Use Zsh native mechanism to detect GNU 'du'

Skip additional call to `grep` and use Zsh native mechanism to detect
GNU version of `du`.

Further, Remove redundant `function` clause as per Prezto convention.
main
Indrajit Raychaudhuri 4 years ago committed by Indrajit Raychaudhuri
parent 6eb4021556
commit d3d79bbe74

@ -6,12 +6,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
function dut {
(( $# == 0 )) && set -- *
# function dut {
if grep -q -i 'GNU' < <(du --version 2>&1); then
(( $# == 0 )) && set -- *
if [[ ${(@M)${(f)"$(du --version 2>&1)"}:#*GNU *} ]]; then
du -khsc "$@" | sort -h -r
else
else
local line size name
local -a record
@ -21,7 +22,6 @@ function dut {
name="$record[2,-1]"
printf "%9.1LfM %s\n" "$size" "$name"
done < <(du -kcs "$@") | sort -n -r
fi
}
fi
dut "$@"
# }

Loading…
Cancel
Save