eza.plugin.zsh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. if ! (( $+commands[eza] )); then
  2. print "zsh eza plugin: eza not found. Please install eza before using this plugin." >&2
  3. return 1
  4. fi
  5. typeset -a _EZA_HEAD
  6. typeset -a _EZA_TAIL
  7. function _configure_eza() {
  8. local _val
  9. # Get the head flags
  10. if zstyle -T ':omz:plugins:eza' 'show-group'; then
  11. _EZA_HEAD+=("g")
  12. fi
  13. if zstyle -t ':omz:plugins:eza' 'header'; then
  14. _EZA_HEAD+=("h")
  15. fi
  16. zstyle -s ':omz:plugins:eza' 'size-prefix' _val
  17. case "${_val:l}" in
  18. binary)
  19. _EZA_HEAD+=("b")
  20. ;;
  21. none)
  22. _EZA_HEAD+=("B")
  23. ;;
  24. esac
  25. # Get the tail long-options
  26. if zstyle -t ':omz:plugins:eza' 'dirs-first'; then
  27. _EZA_TAIL+=("--group-directories-first")
  28. fi
  29. if zstyle -t ':omz:plugins:eza' 'git-status'; then
  30. _EZA_TAIL+=("--git")
  31. fi
  32. if zstyle -t ':omz:plugins:eza' 'icons'; then
  33. _EZA_TAIL+=("--icons=auto")
  34. fi
  35. zstyle -s ':omz:plugins:eza' 'color-scale' _val
  36. if [[ $_val ]]; then
  37. _EZA_TAIL+=("--color-scale=$_val")
  38. fi
  39. zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
  40. if [[ $_val == (gradient|fixed) ]]; then
  41. _EZA_TAIL+=("--color-scale-mode=$_val")
  42. fi
  43. zstyle -s ':omz:plugins:eza' 'time-style' _val
  44. if [[ $_val ]]; then
  45. _EZA_TAIL+=("--time-style='$_val'")
  46. fi
  47. if zstyle -t ":omz:plugins:eza" "hyperlink"; then
  48. _EZA_TAIL+=("--hyperlink")
  49. fi
  50. }
  51. _configure_eza
  52. function _alias_eza() {
  53. local _head="${(j::)_EZA_HEAD}$2"
  54. local _tail="${(j: :)_EZA_TAIL}"
  55. alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
  56. }
  57. _alias_eza la la
  58. _alias_eza ldot ld ".*"
  59. _alias_eza lD lD
  60. _alias_eza lDD lDa
  61. _alias_eza ll l
  62. _alias_eza ls
  63. _alias_eza lsd d
  64. _alias_eza lsdl dl
  65. _alias_eza lS "l -ssize"
  66. _alias_eza lT "l -snewest"
  67. unfunction _alias_eza
  68. unfunction _configure_eza
  69. unset _EZA_HEAD
  70. unset _EZA_TAIL