dotfiles/.local/bin/scripts/s
2025-02-04 11:57:49 +01:00

10 lines
573 B
Bash
Executable file

#!/bin/sh
# shows size statistics for subfolders
# max depth is equal to the first argument if it is a number or 1
export chars=$(expr $(tput cols) - 60)
case "$1" in (+*) size=${1#+}G; depth=2; shift;; esac
case "$1" in ([0-9]) depth=$1; shift;; esac
du="du --max-depth '${depth:-1}' -xha"
($du -t ${size:-50M} "$@" | sort -h | grep -v "^0") |
while read line; do echo "$(tput smso)$line$(tput rmso) $(pacman -Qqo $(echo $line | awk '{print $2}') 2>/dev/null | paste -s -d',' | sed "s/\(.\{${chars}\}\).*/\1.../")"; done || #| column -t ||
($du "$@" | sort -h | tail)