Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nisavid/zsh-config

Zsh configuration
https://github.com/nisavid/zsh-config

catppuccin zsh zsh-config zshell zshrc

Last synced: 26 days ago
JSON representation

Zsh configuration

Awesome Lists containing this project

README

        

# 🖳 Zsh Configuration

My [**Zsh**] configuration. Fast, convenient, and pretty.

[**Zsh**]: https://zsh.sourceforge.io

- [☑️ Features](#readme-features)
- [🫀 Core](#readme-core)
- [⚡️ Performance](#readme-performance)
- [🏪 Convenience](#readme-convenience)
- [🦋 Visuals](#readme-visuals)
- [🛠️ Installation](#readme-installation)
- [Installation Method: Using Chezmoi](#installation-method-using-chezmoi)
- [Installation Method: Manual](#installation-method-manual)

## ☑️ Features

### 🫀 Core

- Plugin manager: [**Zi**]

This is the [better-maintained] but [less popular][compare Zi] resurrection
of **zdharma/zinit**, f.k.a. **zdharma/zplugin**.

[**Zi**]: https://zshell.dev
[better-maintained]: https://github.com/orgs/z-shell/discussions/138
[compare Zi]: https://www.githubcompare.com/z-shell/zi+zdharma-continuum/zinit

### ⚡️ Performance

- [**Powerlevel10k Instant Prompt**] provides an instantly interactive prompt
while `zshrc` is loading.

- Zi's internals and features are highly optimized for performance,
especially at load time.

- It compiles all plugins' Zsh scripts to Zsh word code (`[…].zwc`).

- Zi [light loading] and [turbo mode] are employed for fast and asynchronous
loading of plugins.

- All completion files (including those installed system-wide
and those generated by external tools) are managed by Zi.
[`zicompinit_fast`] is employed (invoked asynchronously)
so that `.zcompdump` is generated on [`compinit`] only once a day.

- Zsh features are employed instead of alternatives that entail subprocesses,
subshells, I/O, and other slow operations.

For example:

- Zsh [expansions] and [arrays] are favored over forking subshells to execute
`head`, `tail`, `cut`, `grep`, `sed`, and the like.

- Command existence is checked/resolved via [`$commands`] (a fast
hash lookup) rather than forking a subshell to execute `command -v`
(a slow interrogation of the filesystem) or `which` (likewise, but with an
additional program execution).

- Fetched and generated files (e.g. completions, themes) are cached
and only refreshed on explicit update.

[**Powerlevel10k Instant Prompt**]: https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#instant-prompt
[`$commands`]: https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#index-commands
[`compinit`]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Use-of-compinit
[`zicompinit_fast`]: https://wiki.zshell.dev/docs/guides/commands#calling-compinit-with-turbo-mode
[arrays]: https://zsh.sourceforge.io/Doc/Release/Parameters.html#Array-Parameters
[expansions]: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Expansion
[light loading]: https://wiki.zshell.dev/docs/getting_started/overview#plugin-and-snippet-loading
[turbo mode]: https://wiki.zshell.dev/docs/getting_started/overview#turbo-mode-zsh--53

### 🏪 Convenience

- Useful and sensible settings for [Zsh options] and [Zsh parameters].

- Conformance to the [XDG Base Directory Specification] (as much as possible)
in order to provide a clean and consistent home directory layout

- For the full effect, install my
[XDG Base Directory `environment.d` configuration]
in `~/.config/environment.d/`.

- Zi update (`zi-update`, alias `zup`) handles all updates,
including refreshing the cached instances of fetched/generated files.

- Completions for all the things:

- Fancy completions configuration via [**zsh-fancy-completions**]

- System-wide completions managed by Zi via [**system-completions**]

- Additional completions via [**zsh-completions**]

- Generated completions:

- Python CLI apps via [**shtab**]

- `cog`

- `elm` via [**kraklin/elm.plugin.zsh**]

- `kdesrc-build`

- `pip`, `pipenv`, `pipx`

- `pnpm`

- `rye`

- Auto-suggestions via [**zsh-autosuggestions**]

- Multi-word history search via [**H-S-MW**]

This is the better-maintained but [less popular][compare H-S-MW] resurrection
of **zdharma/history-search-multi-word**.

- Common-sense integrations:

- Set terminal title

- Sane paste behavior via [`bracketed-paste-magic`]

- Automatically detect and use [`node_modules/.bin`]

- Awesome helpers:

- Help:

- `help` (alias: `?`): Get help via `run-help` or `man`

- `ghcs-shell`/`ghcs-gh`/`ghcs-git` (alias: `??`/`??gh`/`??git`):
Request a shell/`gh`/`git` command
from [**GitHub Copilot**][GitHub Copilot CLI]
given a natural-language description

- `sgpts`/`sgpt4s` (alias: `???`/`????`): Request a shell command from
GPT/GPT-4 via [**ShellGPT**] given a natural-language description

- Filesystem:

- `in-dir` (alias: `ind`): Run the given command in the given directory

- `mkcd`: Create the given directory and change into it

- `mktemp`/`mktempd`: Create a temporary file/directory with the system's
`mktemp` command, but use `$XDG_RUNTIME_DIR` as the default location

- `pprint-file` (alias: `pf`): Pretty-print a file

- `diff-fancy` (alias: `d`): `diff --unified` piped
through [`diff-so-fancy`]

- Expressiveness:

- Enabled from the community contributions bundled with Zsh:

- `throw` and `catch`

- `zargs`

- [`zmv`] and its siblings `zcp` and `zln`

- Higher-order functions via [**zsh-functional**]

- Security:

- `wrap-with-secret-from-kwallet`: Wrap a command with an environment
variable containing sensitive information (e.g. API key, password),
retrieving the value from [**KWallet**] via `kwallet-query`

- Introspection:

- `pprint-zfunc` (alias: `pfn`): Pretty-print the source code
of a Zsh function

- `realcmdname`: Determine the real underlying command name invoked by a
command (resolving aliases recursively, and ignoring various
command prefixes)

- Global preferences:

- [vi mode]

And more, via [**evil-registers**], [**vi-motions**], and [**vi-quote**]

- Pager: [**bat**]

- `man` pager: [**Neovim**][Neovim :Man]

- Editor: [**Neovim**]

- Browser: [**Firefox**]

[**Firefox**]: https://mozilla.org/firefox
[**H-S-MW**]: https://github.com/z-shell/H-S-MW
[**KWallet**]: https://apps.kde.org/kwalletmanager5
[**Neovim**]: https://neovim.io
[**ShellGPT**]: https://github.com/TheR1D/shell_gpt
[**bat**]: https://github.com/sharkdp/bat
[**evil-registers**]: https://github.com/zsh-vi-more/evil-registers
[**kraklin/elm.plugin.zsh**]: https://github.com/kraklin/elm.plugin.zsh
[**shtab**]: https://github.com/iterative/shtab
[**system-completions**]: https://github.com/z-shell/system-completions
[**vi-motions**]: https://github.com/zsh-vi-more/vi-motions
[**vi-quote**]: https://github.com/zsh-vi-more/vi-quote
[**zsh-autosuggestions**]: https://github.com/z-users/zsh-autosuggestions
[**zsh-completions**]: https://github.com/zsh-users/zsh-completions
[**zsh-fancy-completions**]: https://github.com/z-shell/zsh-fancy-completions
[**zsh-functional**]: https://github.com/Tarrasch/zsh-functional
[GitHub Copilot CLI]: https://docs.github.com/en/copilot/github-copilot-in-the-cli
[Neovim :Man]: https://neovim.io/doc/user/filetype.html#%3AMan
[XDG Base Directory Specification]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
[XDG Base Directory `environment.d` configuration]: https://github.com/nisavid/dotfiles/blob/main/home/dot_config/environment.d/10-xdg.conf
[Zsh options]: https://zsh.sourceforge.io/Doc/Release/Options.html
[Zsh parameters]: https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Used-By-The-Shell
[`bracketed-paste-magic`]: https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#Widgets
[`diff-so-fancy`]: https://github.com/so-fancy/diff-so-fancy
[`node_modules/.bin`]: https://docs.npmjs.com/cli/configuring-npm/folders
[`zmv`]: https://zsh.sourceforge.io/Guide/zshguide05.html#l143
[compare H-S-MW]: https://www.githubcompare.com/z-shell/h-s-mw+zdharma-continuum/history-search-multi-word
[vi mode]: https://zsh.sourceforge.io/Guide/zshguide04.html#l78

### 🦋 Visuals

- Prompt theme: [**Powerlevel10k**]

- Feature-rich syntax highlighting using [**F-Sy-H**]

This is the better-maintained but [less popular][compare F-Sy-H] resurrection
of **zdharma/fast-syntax-highlighting**.

- Auto-colorization of numerous commands' output via [**Generic Colouriser**] (`grc`)

- Auto-colorization and paging of `--help` output via a global alias
that pipes it through [`bat --plain --language=help`]

- [**Catppuccin**] themes for all the things:

- [**F-Sy-H**] via [**catppuccin/zsh-fsh**]

- [**fzf**] via [**catppuccin/fzf**]

- [**Glamour**] via [**catppuccin/glamour**]

- [**Lazygit**] via [**catppuccin/lazygit**]

- `LS_COLORS` generated with [**vivid**] using the **catppuccin-mocha** theme.

- More in [my dotfiles]

[**Catppuccin**]: https://catppuccin.com
[**F-Sy-H**]: https://github.com/z-shell/F-Sy-H
[**Generic Colouriser**]: https://kassiopeia.juls.savba.sk/~garabik/software/grc.html
[**Glamour**]: https://github.com/charmbracelet/glamour
[**Lazygit**]: https://github.com/jesseduffield/lazygit
[**Powerlevel10k**]: https://github.com/romkatv/powerlevel10k
[**catppuccin/fzf**]: https://github.com/catppuccin/fzf
[**catppuccin/glamour**]: https://github.com/catppuccin/glamour
[**catppuccin/lazygit**]: https://github.com/catppuccin/lazygit
[**catppuccin/zsh-fsh**]: https://github.com/catppuccin/zsh-fsh
[**fzf**]: https://github.com/junegunn/fzf
[**vivid**]: https://github.com/sharkdp/vivid
[`bat --plain --language=help`]: https://github.com/sharkdp/bat#highlighting---help-messages
[compare F-Sy-H]: https://www.githubcompare.com/z-shell/f-sy-h+zdharma-continuum/fast-syntax-highlighting

## 🛠️ Installation

### Installation Method: Using Chezmoi

Install [my dotfiles]. That's all!

Alternatively, include this configuration in your own [**chezmoi**] repository
using its [corresponding chezmoi-external configuration]
and [`~/.zshenv` symlink].

[**chezmoi**]: https://chezmoi.io
[`~/.zshenv` symlink]: https://github.com/nisavid/dotfiles/blob/main/home/symlink_dot_zshenv
[corresponding chezmoi-external configuration]: https://github.com/nisavid/dotfiles/blob/main/home/.chezmoiexternals/zsh-config.toml
[my dotfiles]: https://github.com/nisavid/dotfiles

### Installation Method: Manual

#### Clone the configuration

```shell
git clone https://github.com/nisavid/zsh-config ~/.config/zsh
```

#### Link .zshenv

```shell
ln -s ~/.config/zsh/zshenv.zsh ~/.zshenv
```

#### Start Zsh

```shell
zsh
```