Home

Awesome

Not Your Average Async ZSH Shell Prompt

<center>

Project Logo

</center>

Inspired by:

Selling Points:

Demo Of GoPrompt With ZLE

GoPrompt is lightning fast, and truly and faithfully asynchronous prompt based on ZLE File Descriptor co-routines, with default theme/query implementation in a very simple to extend GoLang package.

Quick Install

The latest releases are available under:

https://github.com/NonLogicalDev/shell.async-goprompt/releases/latest

Install latest using:

curl -sfL https://raw.githubusercontent.com/NonLogicalDev/shell.async-goprompt/main/install.sh | bash -

This will install goprompt under ~/.local/bin. Please ensure that it is in your $PATH.

Alternatively if you have GoLang installed you can install it directly from source:

go install github.com/NonLogicalDev/shell.async-goprompt/cmd/goprompt@latest

And if you want to build it yourself and/or contribute, feel free to checkout #Build Instructions section below, for guidance on how to build it from source locally.

Install Into Shell

Try for one session:

$ eval "$(goprompt install zsh)"

Install permanently:

$ goprompt install zsh >> ~/.zshrc

Default Renderer supports:

Example:

# After running this:

	$ ( sleep 570; exit 130 )

# Example prompt with most integrations displayed:

	:: {git:main:&:[+1:-0]} {stg:readme:1/2}
	:: [130] (vifm) (~/U/P/shell.async-goprompt) 9m30s [22:18:42 02/20/23]
	>

# After normal (faster, errorless) execution:

	:: {git:main:&:[+1:-0]} {stg:readme:1/2}
	:: (vifm) (~/U/P/shell.async-goprompt) [22:18:42 02/20/23]
	>

# When outside of VCS root:

	:: ------------------------------
	:: (vifm) (~/U/Projects) [22:18:42 02/20/23]
	>

Features:

Technology / Implementation Details

This is a non-blocking asynchronous prompt based on ZLE File Descriptor Handlers.

The prompt query and rendering can be done via any command as long as it follows a line delimited protocol to communicate between the query and rendering components.

Protocol

The query command output must adhere to a line protocol to be effective in making use of ZLE File Descriptor handler.

The protocol used in my Async ZLE Implementation is dead simple and easy to implement and use. (So easy it initially was fully implemented in a ZSH script)

First of all the protocol is new line and tab delimited, where each line takes the following form:

$KEY1<tab char>$VALUE1
$KEY2<tab char>$VALUE2

This makes key parsing dead simple and allows values to be as complex as desired (so long as they dont contain new lines), for example they can be single line encoded JSON values.

Each empty line triggers a prompt refresh, kind of like a sync singal.

$KEY1<tab char>$VALUE1
$KEY2<tab char>$VALUE2
<empty>
$KEY3<tab char>$VALUE3
$KEY4<tab char>$VALUE4

This allows the prompt to periodically communicate that batch of data is ready. Being judicious in not sending sync signals leads to less visual jitter when prompt re-renders, in response to updated data.

Upon every sync signal renderer gets a newline concatentated list of Key Value Lines on its STDIN, and produces the actual prompt.

Renderer

The only protocol on the renderer is that Renderer is expected to produce ZSH formatted prompt string base on newline delimited list of key values.

Overall the renderer is a bit like a pure React component render function.

Reference

You can find the ZSH/ZLE integration in:

And the main query/rendering logic is implemented in GO

Build Instructions

$ eval "$(gimme 1.20)"
$ make install USR_BIN_DIR="$HOME/bin"
$ goprompt install zsh >> ~/.zshrc