Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust error handling to keep zsh session alive #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 23 additions & 65 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
<div align="center">
<table style="width:100%;height:auto">
<tr><td align="center">
<h1>
<a title="❮ Zsh eza ❯" target="_self" href="https://github.com/z-shell/zsh-eza">
<img style="width:60px;height:60px"
src="https://raw.githubusercontent.com/z-shell/zi/main/docs/images/logo.svg"
alt="Logo" /></a>❮ Zsh eza ❯
</h1>
<h2>
Zsh plugin which replace GNU/ls with <a target="_self" href="https://github.com/eza-community/eza">eza-community/eza</a>
</h2>
<h3>
<a href="https://github.com/orgs/z-shell/discussions/">《❔》Ask a Question </a>
<a href="https://wiki.zshell.dev/search/">《💡》Search Wiki </a>
<a href="https://github.com/z-shell/community/issues/new?assignees=&labels=%F0%9F%91%A5+member&template=membership.yml&title=team%3A+">《💜》Join </a>
<a href="https://digitalclouds.crowdin.com/z-shell/">《🌐》Localize </a>
</h3></td></tr>
<tr>
<td align="center">
<a target="_self" href="https://github.com/z-shell/zsh-eza/actions/workflows/trunk-check.yml">
<img align="center" src="https://github.com/z-shell/zsh-eza/actions/workflows/trunk-check.yml/badge.svg?branch=main" alt="⭕ Trunk Check" />
</a>
<a target="_self" href="https://open.vscode.dev/z-shell/zsh-eza/">
<img
align="center"
src="https://img.shields.io/badge/--007ACC?logo=visual%20studio%20code&logoColor=ffffff"
alt="Visual Studio Code"
/>
</a>
</td>
</tr>
<tr><td><img align="center" style="width:100%;height:auto" src="https://user-images.githubusercontent.com/59910950/165784269-3a8a8bfe-f291-4a33-aac9-1afa2b7b767f.png" />
</td></tr></table></div>
# 📂 zsh-eza

a zsh plugin which replaces GNU/ls with <a target="_self" href="https://github.com/eza-community/eza">eza-community/eza</a>

### Environment variables

Expand All @@ -55,55 +24,44 @@ alias tree='eza --tree $eza_params'

## Install

The `eza` should be present to use this plugin. Install `eza` with Zi:
`eza` should be present to use this plugin. Install `eza` with Cargo:

```shell
zi ice from'gh-r' as'program' sbin'**/eza -> eza' atclone'cp -vf completions/eza.zsh _eza'
zi light eza-community/eza
cargo install eza
```

### With [Zi](https://github.com/z-shell/zi)

To install add to the `.zshrc` file:
or your package manager of choice.

```shell
zi light z-shell/zsh-eza
```
### With [Zi](https://github.com/z-shell/zi)

Install only if eza exists and enable auto list directories:
Add the following to your `~/.zshrc`

```shell
zi ice has'eza' atinit'AUTOCD=1'
zi light z-shell/zsh-eza
zi light givensuman/zsh-eza
```

Install only if eza exists and enable auto list directories in turbo mode:

```shell
zi ice wait lucid has'eza' atinit'AUTOCD=1'
zi light z-shell/zsh-eza
```
### With [Oh My Zsh](https://ohmyz.sh/)

Install only if eza exists and enable auto list directories in turbo mode with the for syntax:
Clone the repository

```shell
zi wait lucid for \
has'eza' atinit'AUTOCD=1' \
z-shell/zsh-eza
git clone https://github.com/givensuman/zsh-eza \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-eza
```

### With [Oh My Zsh](https://ohmyz.sh/)

Clone the repository and add `zsh-eza` to the plugins array of your zshrc file:
and add `zsh-eza` to the plugins array of your `~/.zshrc`

```sh
~/.oh-my-zsh/custom/plugins
```

```sh
plugins=(... zsh-eza)
plugins=(
...
zsh-eza
)
```

### With Zplug

Add `zplug z-shell/zsh-eza` to your `~/.zshrc` and re-open your terminal session.
Add the following to your `~/.zshrc`

```shell
zplug givensuman/zsh-eza
```
16 changes: 5 additions & 11 deletions functions/.zsh-eza
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
#
# Copyright (c) 2022 Salvydas Lukosius

if [[ $TERM == 'dumb' ]]; then
return 1
print "Error loading zsh-eza: plugin used in a dumb terminal." >&2
return
fi

builtin emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
Expand Down Expand Up @@ -32,13 +28,11 @@ if (( $+commands[eza] )); then

[[ "$AUTOCD" = <-> ]] && enable_autocd="$AUTOCD"
if [[ "$enable_autocd" == "1" ]]; then
# Function for cd auto list directories
# Function to call eza when changing directory
→auto-eza() { command eza $eza_params; }
[[ $chpwd_functions[(r)→auto-eza] == →auto-eza ]] || chpwd_functions=( →auto-eza $chpwd_functions )
fi
else
print "Please install eza before using this plugin." >&2
return 1
print "Error loading zsh-eza: eza not found." >&2
return
fi

return 0
13 changes: 2 additions & 11 deletions zsh-eza.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
#
# Copyright (c) 2022 Salvydas Lukosius
#
# Zsh Plugin Standard
# https://wiki.zshell.dev/community/zsh_plugin_standard#zero-handling
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
0="${${(M)0:#/*}:-$PWD/$0}"
Expand All @@ -12,7 +6,7 @@
typeset -gA Plugins
Plugins[ZSH_EZA]="${0:h}"

# https://wiki.zshell.dev/community/zsh_plugin_standard#funtions-directory
# https://wiki.zshell.dev/community/zsh_plugin_standard#functions-directory
if [[ $PMSPEC != *f* ]]; then
fpath+=( "${0:h}/functions" )
fi
Expand All @@ -21,9 +15,6 @@ autoload -Uz .zsh-eza

# Load plugin
(( ${+functions[.zsh-eza]} )) && {
.zsh-eza; (( $? )) && {
print "Error loading zsh-eza plugin, exit code: $?"
exit 1
}
.zsh-eza
}