[Assorted-commits] SF.net SVN: assorted:[1616] shell-tools/trunk/src/bash-commons/bashrc.bash
Brought to you by:
yangzhang
From: <yan...@us...> - 2010-04-03 15:13:58
|
Revision: 1616 http://assorted.svn.sourceforge.net/assorted/?rev=1616&view=rev Author: yangzhang Date: 2010-04-03 15:13:52 +0000 (Sat, 03 Apr 2010) Log Message: ----------- added cp-p Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-02 13:50:14 UTC (rev 1615) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-03 15:13:52 UTC (rev 1616) @@ -714,6 +714,25 @@ sudo su - -c "toast $(quote "$@")" } +# From <http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/> +cp-p() { + strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | + awk '{ + count += $NF + if (count % 10 == 0) { + percent = count / total_size * 100 + printf "%3d%% [", percent + for (i=0;i<=percent;i++) + printf "=" + printf ">" + for (i=percent;i<100;i++) + printf " " + printf "]\r" + } + } + END { print "" }' total_size=$(stat -c '%s' "${1}") count=0 +} + #function set_title() { # if [ $# -eq 0 ] ; then # eval set -- "$PWD" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |