From 58c60b12a7fac13673185de87083b2e23393e96f Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Sat, 16 Jun 2012 14:53:33 +0800 Subject: =?UTF-8?q?bash=5Finclude:=20=E6=94=B9=E9=80=B2=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E7=9B=AE=E9=8C=84=E5=AE=B9=E9=87=8F=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/bash_include b/bash_include index 572f671..a6e63c3 100644 --- a/bash_include +++ b/bash_include @@ -107,7 +107,7 @@ function compile_all () printf "$1: Unknown suffix (\e[1;33mskipped\e[0m)\n" fi [ "$?" '!=' "0" ] && printf\ - '\e[1;31mError\e[0m while compiling file\n' + '\e[1;31mError\e[0m while compiling file\n' shift done return 0 @@ -147,6 +147,15 @@ function mkscreenacl () done } +function get_directory_size () +{ + du -s "$1" | { + read -d " " dirsize + echo "$dirsize" + read throwaway + } +} + ########## Background ########## alias bgr=bgrun @@ -299,7 +308,23 @@ function bgclean () function bgdu () { - du -a "$bgrunfiledir" + local -i j=1 + { + echo " INDEX SIZE PID COMMAND" + for i in `find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | sort` + do + head -n 1 "$i" | { + local procpid + local cmdline + read -d ' ' procpid + read cmdline + printf "%6d %8d (%5d) %s\n" "$j" \ + "`get_directory_size "$i"`" \ + "$procpid" "$cmdline" + } + j=$j+1 + done + } | $PAGER } ########## Background End ########## @@ -506,12 +531,16 @@ function trash_du () { split_arguments "$@" local oneline + local -i i=1 find "$trashdir" -maxdepth 1 -mindepth 1 | sort | { while read oneline do - echo "'$oneline'" + printf "%6d %8d %s\n" "$i" \ + "`get_directory_size "$oneline"`" \ + "`cat "$oneline/information.path"`" + i=$i+1 done - } | xargs -n 10 "${prefixlist[@]}" du -s + } | $PAGER unset arglist unset prefixlist } @@ -912,6 +941,7 @@ function help_function () set_console_title x createdir_askmode dirname x split_arguments [arguments ...] + x get_directory_size dirname ENDHELPMSG } && return 0 local current_charset=`echo "$LC_ALL" | cut -d . -f 2` -- cgit v1.2.3