mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-01-10 12:26:46 +00:00
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.
This commit is contained in:
parent
6eb4021556
commit
d3d79bbe74
@ -6,10 +6,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
function dut {
|
# function dut {
|
||||||
|
|
||||||
(( $# == 0 )) && set -- *
|
(( $# == 0 )) && set -- *
|
||||||
|
|
||||||
if grep -q -i 'GNU' < <(du --version 2>&1); then
|
if [[ ${(@M)${(f)"$(du --version 2>&1)"}:#*GNU *} ]]; then
|
||||||
du -khsc "$@" | sort -h -r
|
du -khsc "$@" | sort -h -r
|
||||||
else
|
else
|
||||||
local line size name
|
local line size name
|
||||||
@ -22,6 +23,5 @@ function dut {
|
|||||||
printf "%9.1LfM %s\n" "$size" "$name"
|
printf "%9.1LfM %s\n" "$size" "$name"
|
||||||
done < <(du -kcs "$@") | sort -n -r
|
done < <(du -kcs "$@") | sort -n -r
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
dut "$@"
|
# }
|
||||||
|
Loading…
Reference in New Issue
Block a user