elf.zsh
is a framework for creating your own fully asynchronous zsh prompts, using its own library for zsh-native non-blocking computation. (aui.zsh
)
Its creation was motivated by the slowness and lack of configurability of existing zsh prompts.
Using elf is very simple.
In essence you only need to perform these actions:
- load the
elf.zsh
library - register your preferred synchronous and asynchronous sections
- design your prompt and rprompt
- load the
elf_load.zsh
library - initialize elf
A fully functional elf setup might look like this:
source $ZSH_PLUGIN_DIR/elf/elf.zsh
elf_add la "%~ > "
elf_add ra '%1v'
elf_async git_rev "git rev-parse --short HEAD 2>/dev/null" 'psvar[1]=$1'
source $ZSH_PLUGIN_DIR/elf/elf_load.zsh
elf_setup
With this setup your left prompt shows the cwd and the right prompt shows the currently active git branch. The git branch is fetched and displayed fully asynchronously.
Coming soon. Elf is currently still undergoing significant API changes
If you are a beginner zsh user you might want to first take a look at the village
parent directory of this repo.
It contains predefined elf configurations that you may use directly or as a base for your own creations.
I do not know how to reliably benchmark prompts return times, however I personally perceive elf to be significantly faster than nearly all other solutions I have tried.
Elf also aims to be as small as possible and to not rely on external dependencies.
prompt | performance | sloc (lines -blank -comments) | external dependencies |
---|---|---|---|
alien | noticable delays | 511 (alien libs) + 1390 (external) | promptlib, zsh-256color, zsh-async |
pure | no delay | 372 (pure.zsh) + 292 (async.zsh) | async.zsh (copied into repo) |
geometry | noticeable delays | ||
spaceship | |||
powerlevel10k | |||
elf | no or very small delay | 98 (elf.zsh) + 68 (elf_load.zsh) + 48 (aui.zsh) | none |
From my investigation, pure is much much faster than any other prompt framework. I would like to investigate why that is and improve village with this information.
zprof
reports that async takes up a considerable amount of time.- It seems like pure uses what it calls a preprompt mechanism.
- Pure might not actually be any faster than elf
elf
does not natively support transient prompts, because most obvious mechanisms result in noticeable delays and stuttering.
Themes that want to employ transient prompts thus currently have to rely on implementing their own ad-hoc mechanisms.
aui
is a zsh library responsible for managing asynchronous computations.
It was specifically designed for elf
, but may also be used separately.
Documentation can be found in the commented source file.