mirror of https://github.com/akelge/vim
35 lines
1.1 KiB
Bash
35 lines
1.1 KiB
Bash
#######################################################################################
|
|
# Functions
|
|
|
|
# cdb - Goes to folder by complete path
|
|
function cdb { cd `dirname $1` }
|
|
|
|
# hist - Grep from history
|
|
function hist { grep -i $* $HISTFILE }
|
|
|
|
# hdu - Human readable report of files and directories sizes
|
|
# *Same behaviour as du*
|
|
function hdu () {
|
|
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;
|
|
}'
|
|
}
|
|
# list total size in . directory
|
|
function dust () { hdu -s * }
|
|
|
|
# vim: set ts=4 sw=4 tw=0 ft=zsh :
|