40_linux.zsh 857 B

12345678910111213141516171819202122232425262728293031323334
  1. #
  2. # Linux Stuff
  3. #
  4. #
  5. # Alias / Functions
  6. #
  7. mdstat() {
  8. if [ -f /proc/mdstat ]; then
  9. cat /proc/mdstat
  10. else
  11. print "Linux Software RAID not available on this system."
  12. return 1
  13. fi
  14. }
  15. # Fancy cp with progressbar (using strace)
  16. # from http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
  17. cp_p() {
  18. strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | awk '{
  19. count += $NF
  20. if (count % 10 == 0) {
  21. percent = count / total_size * 100
  22. printf "%3d%% [", percent
  23. for (i=0;i<=percent;i++)
  24. printf "="
  25. printf ">"
  26. for (i=percent;i<100;i++)
  27. printf " "
  28. printf "]\r"
  29. }
  30. }
  31. END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
  32. }