diff options
| author | Pandu E POLUAN <pepoluan@gmail.com> | 2024-02-29 15:40:40 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 09:40:40 +0100 |
| commit | 6a65ac90259d87f7549c581372403405ef01b7d2 (patch) | |
| tree | 7772177f9d961bbfce119f9715ba575a72e32e1e /plugins/eza/eza.plugin.zsh | |
| parent | 51bf9fc2def19f1d3059c15059df21ddddb518fd (diff) | |
| download | zsh-6a65ac90259d87f7549c581372403405ef01b7d2.tar.gz zsh-6a65ac90259d87f7549c581372403405ef01b7d2.tar.bz2 zsh-6a65ac90259d87f7549c581372403405ef01b7d2.zip | |
feat(eza): create plugin (#12237)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diffstat (limited to 'plugins/eza/eza.plugin.zsh')
| -rw-r--r-- | plugins/eza/eza.plugin.zsh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/plugins/eza/eza.plugin.zsh b/plugins/eza/eza.plugin.zsh new file mode 100644 index 000000000..6d7f720bd --- /dev/null +++ b/plugins/eza/eza.plugin.zsh @@ -0,0 +1,62 @@ +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 + zstyle -s ':omz:plugins:eza' 'time-style' _val + if [[ $_val ]]; then + _EZA_TAIL+=("--time-style='$_val'") + 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 |
