eza.plugin.zsh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. zstyle -s ':omz:plugins:eza' 'time-style' _val
  33. if [[ $_val ]]; then
  34. _EZA_TAIL+=("--time-style='$_val'")
  35. fi
  36. }
  37. _configure_eza
  38. function _alias_eza() {
  39. local _head="${(j::)_EZA_HEAD}$2"
  40. local _tail="${(j: :)_EZA_TAIL}"
  41. alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
  42. }
  43. _alias_eza la la
  44. _alias_eza ldot ld ".*"
  45. _alias_eza lD lD
  46. _alias_eza lDD lDa
  47. _alias_eza ll l
  48. _alias_eza ls
  49. _alias_eza lsd d
  50. _alias_eza lsdl dl
  51. _alias_eza lS "l -ssize"
  52. _alias_eza lT "l -snewest"
  53. unfunction _alias_eza
  54. unfunction _configure_eza
  55. unset _EZA_HEAD
  56. unset _EZA_TAIL