Linux.zsh 958 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #
  2. # Linux Stuff
  3. #
  4. if [ -r /etc/debian_version ]; then
  5. source "$DOTZSHDIR/os.d/Debian.zsh"
  6. fi
  7. if [ "$TERM" != 'dumb' ]; then
  8. if -exe dircolors; then
  9. eval $(dircolors -b)
  10. fi
  11. alias ls='ls -h --color=auto'
  12. alias l='ls -lh --color=auto'
  13. else
  14. alias ls='ls -h'
  15. alias l='ls -lh'
  16. fi
  17. # Fancy cp with progressbar (using strace)
  18. # from http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
  19. cp_p() {
  20. strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | awk '{
  21. count += $NF
  22. if (count % 10 == 0) {
  23. percent = count / total_size * 100
  24. printf "%3d%% [", percent
  25. for (i=0;i<=percent;i++)
  26. printf "="
  27. printf ">"
  28. for (i=percent;i<100;i++)
  29. printf " "
  30. printf "]\r"
  31. }
  32. }
  33. END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
  34. }