add ds-function to calculate dir sizes and sort them

This commit is contained in:
Rico Ullmann 2016-04-24 14:26:04 +02:00
parent eba2c94c7f
commit 8636b82892
1 changed files with 27 additions and 0 deletions

27
init.fish Normal file
View File

@ -0,0 +1,27 @@
function df --description 'df should always be human readable'
command df -h $argv
end
function ds --description 'calculate size of current or a given dir and sort by size'
switch (count $argv)
case 0
du -hsx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case 1
du -hx $argv .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case \*
echo "Only none or 1 argument is valid!"
return 1
end
end