plugins/base: rewrite `usage()`

Reimplement disk usage function using Bash syntax and simpler layout, without having to invoke an external binary.
pull/1930/head
John D Pell 2021-09-23 22:47:55 -07:00
parent 5cb7522713
commit c3f45b2ae7
1 changed files with 9 additions and 16 deletions

View File

@ -117,25 +117,18 @@ function banish-cookies ()
ln -s /dev/null ~/.macromedia
}
function usage ()
{
function usage() {
about 'disk usage per directory, in Mac OS X and Linux'
param '1: directory name'
group 'base'
if [[ "$OSTYPE" == 'darwin'* ]]; then
if [ -n "$1" ]; then
du -hd 1 "$1"
else
du -hd 1
fi
elif [[ "$OSTYPE" = 'linux'* ]]; then
if [[ -n "$1" ]]; then
du -h --max-depth=1 "$1"
else
du -h --max-depth=1
fi
fi
case $OSTYPE in
*'darwin'*)
du -hd 1 "$@"
;;
*'linux'*)
du -h --max-depth=1 "$@"
;;
esac
}
if [[ ! -e "${BASH_IT}/plugins/enabled/todo.plugin.bash" \