Linux.zsh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. if [ -r ~/.dircolors ]; then
  10. eval $(dircolors -b ~/.dircolors)
  11. else
  12. eval $(dircolors -b)
  13. fi
  14. fi
  15. alias ls='ls -h --color=auto'
  16. alias l='ls -lh --color=auto'
  17. else
  18. alias ls='ls -h'
  19. alias l='ls -lh'
  20. fi
  21. #
  22. # Alias / Functions
  23. #
  24. mdstat() {
  25. if [ -f /proc/mdstat ]; then
  26. cat /proc/mdstat
  27. else
  28. print "Linux Software RAID not available on this system."
  29. return 1
  30. fi
  31. }
  32. # Fancy cp with progressbar (using strace)
  33. # from http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
  34. cp_p() {
  35. strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | awk '{
  36. count += $NF
  37. if (count % 10 == 0) {
  38. percent = count / total_size * 100
  39. printf "%3d%% [", percent
  40. for (i=0;i<=percent;i++)
  41. printf "="
  42. printf ">"
  43. for (i=percent;i<100;i++)
  44. printf " "
  45. printf "]\r"
  46. }
  47. }
  48. END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
  49. }