mirror of
https://github.com/akelge/zsh
synced 2025-07-03 21:19:06 +00:00
migration
This commit is contained in:
17
zsh.d/zshfunctions/hdu
Normal file
17
zsh.d/zshfunctions/hdu
Normal file
@ -0,0 +1,17 @@
|
||||
du -kc $* | sort -nr | awk '{
|
||||
# Prepare human readable
|
||||
if($1>=1024*1024) { size=$1/1024/1024; unit="G" }
|
||||
else if($1>=1024) { size=$1/1024; unit="M" }
|
||||
else { size=$1; unit="K" };
|
||||
format="%10.2f%s";
|
||||
hsize=sprintf(format,size,unit);
|
||||
|
||||
# Remove $1 (size), then removes " " at the start of $0
|
||||
$1=""; thepath=$0; sub(/^ /,"",thepath);
|
||||
|
||||
# Print size and path (directories are bolded)
|
||||
if ( system("[ -d \""thepath"\" ]") )
|
||||
printf "%-8s %s\n",hsize,thepath;
|
||||
else
|
||||
printf "%-8s \033[1m%s\033[0m/\n",hsize,thepath;
|
||||
}'
|
Reference in New Issue
Block a user