summaryrefslogtreecommitdiff
path: root/plugins/eza
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2026-01-04 22:47:54 -0800
committerTuowen Zhao <ztuowen@gmail.com>2026-01-04 22:47:54 -0800
commit2aa4cb7a52b28722816ecfd55f3b06293332c55c (patch)
treef02a9f3d59d109c70caf932a24e43368994e0e8c /plugins/eza
parent7e951c254e779ff0620537cf43ca69dd878387b4 (diff)
parentd23d3ea69fdb839088e6e5589557cce77b34aaf8 (diff)
downloadzsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.tar.gz
zsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.tar.bz2
zsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.zip
Merge remote-tracking branch 'github/master'HEADmaster
Diffstat (limited to 'plugins/eza')
-rw-r--r--plugins/eza/README.md144
-rw-r--r--plugins/eza/eza.plugin.zsh76
2 files changed, 220 insertions, 0 deletions
diff --git a/plugins/eza/README.md b/plugins/eza/README.md
new file mode 100644
index 000000000..bec1f85cb
--- /dev/null
+++ b/plugins/eza/README.md
@@ -0,0 +1,144 @@
+# eza plugin
+
+This provides aliases that invoke the [`eza`](https://github.com/eza-community/eza) utility rather than `ls`
+
+To use it add `eza` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... eza)
+```
+
+## Configuration
+
+All configurations are done using the `zstyle` command in the `:omz:plugins:eza` namespace.
+
+**NOTE:** The configuring needs to be done prior to OMZ loading the plugins. When the plugin is loaded,
+changing the `zstyle` won't have any effect.
+
+### `dirs-first`
+
+```zsh
+zstyle ':omz:plugins:eza' 'dirs-first' yes|no
+```
+
+If `yes`, directories will be grouped first.
+
+Default: `no`
+
+### `git-status`
+
+```zsh
+zstyle ':omz:plugins:eza' 'git-status' yes|no
+```
+
+If `yes`, always add `--git` flag to indicate git status (if tracked / in a git repo).
+
+Default: `no`
+
+### `header`
+
+```zsh
+zstyle ':omz:plugins:eza' 'header' yes|no
+```
+
+If `yes`, always add `-h` flag to add a header row for each column.
+
+Default: `no`
+
+### `show-group`
+
+```zsh
+zstyle ':omz:plugins:eza' 'show-group' yes|no
+```
+
+If `yes` (default), always add `-g` flag to show the group ownership.
+
+Default: `yes`
+
+### `icons`
+
+```zsh
+zstyle ':omz:plugins:eza' 'icons' yes|no
+```
+
+If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders.
+
+Default: `no`
+
+### `color-scale`
+
+```zsh
+zstyle ':omz:plugins:eza' 'color-scale' all|age|size
+```
+
+Highlight levels of field(s) distinctly. Use comma(,) separated list of `all`, `age`, `size`
+
+Default: `none`
+
+### `color-scale-mode`
+
+```zsh
+zstyle ':omz:plugins:eza' 'color-scale-mode' gradient|fixed
+```
+
+Choose the mode for highlighting:
+
+- `gradient` (default) -- gradient coloring
+- `fixed` -- fixed coloring
+
+Default: `gradient`
+
+### `size-prefix`
+
+```zsh
+zstyle ':omz:plugins:eza' 'size-prefix' (binary|none|si)
+```
+
+Choose the prefix to be used in displaying file size:
+
+- `binary` -- use [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) such as "Ki", "Mi", "Gi" and
+ so on
+- `none` -- don't use any prefix, show size in bytes
+- `si` (default) -- use [Metric/S.I. prefixes](https://en.wikipedia.org/wiki/Metric_prefix)
+
+Default: `si`
+
+### `time-style`
+
+```zsh
+zstyle ':omz:plugins:eza' 'time-style' $TIME_STYLE
+```
+
+Sets the `--time-style` option of `eza`. (See `man eza` for the options)
+
+Default: Not set, which means the default behavior of `eza` will take place.
+
+### `hyperlink`
+
+```zsh
+zstyle ':omz:plugins:eza' 'hyperlink' yes|no
+```
+
+If `yes`, always add `--hyperlink` flag to create hyperlink with escape codes.
+
+Default: `no`
+
+## Aliases
+
+**Notes:**
+
+- Aliases may be modified by Configuration
+- The term "files" without "only" qualifier means both files & directories
+
+| Alias | Command | Description |
+| ------ | ----------------- | -------------------------------------------------------------------------- |
+| `la` | `eza -la` | List all files (except . and ..) as a long list |
+| `ldot` | `eza -ld .*` | List dotfiles only (directories shown as entries instead of recursed into) |
+| `lD` | `eza -lD` | List only directories (excluding dotdirs) as a long list |
+| `lDD` | `eza -laD` | List only directories (including dotdirs) as a long list |
+| `ll` | `eza -l` | List files as a long list |
+| `ls` | `eza` | Plain eza call |
+| `lsd` | `eza -d` | List specified files with directories as entries, in a grid |
+| `lsdl` | `eza -dl` | List specified files with directories as entries, in a long list |
+| `lS` | `eza -l -ssize` | List files as a long list, sorted by size |
+| `lT` | `eza -l -snewest` | List files as a long list, sorted by date (newest last) |
diff --git a/plugins/eza/eza.plugin.zsh b/plugins/eza/eza.plugin.zsh
new file mode 100644
index 000000000..60ed1eb27
--- /dev/null
+++ b/plugins/eza/eza.plugin.zsh
@@ -0,0 +1,76 @@
+if ! (( $+commands[eza] )); then
+ print "zsh eza plugin: eza not found. Please install eza before using this plugin." >&2
+ return 1
+fi
+
+typeset -a _EZA_HEAD
+typeset -a _EZA_TAIL
+
+function _configure_eza() {
+ local _val
+ # Get the head flags
+ if zstyle -T ':omz:plugins:eza' 'show-group'; then
+ _EZA_HEAD+=("g")
+ fi
+ if zstyle -t ':omz:plugins:eza' 'header'; then
+ _EZA_HEAD+=("h")
+ fi
+ zstyle -s ':omz:plugins:eza' 'size-prefix' _val
+ case "${_val:l}" in
+ binary)
+ _EZA_HEAD+=("b")
+ ;;
+ none)
+ _EZA_HEAD+=("B")
+ ;;
+ esac
+ # Get the tail long-options
+ if zstyle -t ':omz:plugins:eza' 'dirs-first'; then
+ _EZA_TAIL+=("--group-directories-first")
+ fi
+ if zstyle -t ':omz:plugins:eza' 'git-status'; then
+ _EZA_TAIL+=("--git")
+ fi
+ if zstyle -t ':omz:plugins:eza' 'icons'; then
+ _EZA_TAIL+=("--icons=auto")
+ fi
+ zstyle -s ':omz:plugins:eza' 'color-scale' _val
+ if [[ $_val ]]; then
+ _EZA_TAIL+=("--color-scale=$_val")
+ fi
+ zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
+ if [[ $_val == (gradient|fixed) ]]; then
+ _EZA_TAIL+=("--color-scale-mode=$_val")
+ fi
+ zstyle -s ':omz:plugins:eza' 'time-style' _val
+ if [[ $_val ]]; then
+ _EZA_TAIL+=("--time-style='$_val'")
+ fi
+ if zstyle -t ":omz:plugins:eza" "hyperlink"; then
+ _EZA_TAIL+=("--hyperlink")
+ fi
+}
+
+_configure_eza
+
+function _alias_eza() {
+ local _head="${(j::)_EZA_HEAD}$2"
+ local _tail="${(j: :)_EZA_TAIL}"
+ alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
+}
+
+_alias_eza la la
+_alias_eza ldot ld ".*"
+_alias_eza lD lD
+_alias_eza lDD lDa
+_alias_eza ll l
+_alias_eza ls
+_alias_eza lsd d
+_alias_eza lsdl dl
+_alias_eza lS "l -ssize"
+_alias_eza lT "l -snewest"
+
+unfunction _alias_eza
+unfunction _configure_eza
+unset _EZA_HEAD
+unset _EZA_TAIL