Parent directory

eza.plugin.zsh

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