Skip to content

Commit 04b86dd

Browse files
committed
doc: update README with better description of the project
1 parent 8751a2c commit 04b86dd

File tree

1 file changed

+127
-5
lines changed

1 file changed

+127
-5
lines changed

README.md

Lines changed: 127 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,145 @@
1-
# Async ZLE Based Prompt
1+
# Not Your Average Async ZSH Shell Prompt
22

3-
(Implemented In GoLang)
3+
## Selling Points:
44

5-
## TLDR
5+
* Packs some punch, with lightning speed never seen before!
6+
* This prompt is truly **INSTA**, as fast as no prompt at all.
7+
* Zero lag between pressing enter and being able to type your next command.
8+
* Truly and faithfully asynchroneous, can cope with most bloated Git monorepos out there without introducing lag. **#this_was_the_reason_this_prompt_was_created**
9+
* The only prompt out there with support for **Stacked Git**. **#another_reason**
10+
* Nearly the only prompt out there to use ZLE File Descriptor co-routines effectively.
11+
12+
![Demo Of GoPrompt With ZLE](./assets/Kapture%202022-07-26%20at%2010.45.33.gif "Capture")
13+
14+
GoPrompt is lightning fast, and truly and faithfully asynchroneous prompt based on ZLE File Descriptor co-routines, with default implementation in a simple GoLang package.
15+
16+
## Install Today
17+
18+
I am periodically uploding new versions of pre-built binaries under `Releases`:
19+
20+
https://github.com/NonLogicalDev/shell.async-goprompt/releases/latest
21+
22+
Alternatively if you have `GoLang` installed you can install it directly from source:
23+
24+
```
25+
go install github.com/NonLogicalDev/shell.async-goprompt/cmd/goprompt@latest
26+
```
27+
28+
And if you want to build it yourself and/or contribute, feel free to checkout [#Install](#install) section below, for instruction of how to build it from source locally.
29+
30+
## Default Renderer supports:
31+
32+
### Example:
33+
34+
```
35+
# After running this:
36+
$ ( sleep 570; exit 130 )
37+
38+
# Example prompt with most integrations displayed:
39+
:: {git:main:&:[+1:-0]} {stg:readme:1/2}
40+
:: [130] (vifm) (~/U/P/shell.async-goprompt) 9m30s [22:18:42 02/20/23]
41+
>
42+
43+
# After normal (faster, errorless) execution:
44+
:: {git:main:&:[+1:-0]} {stg:readme:1/2}
45+
:: (vifm) (~/U/P/shell.async-goprompt) [22:18:42 02/20/23]
46+
>
47+
48+
# When outside of VCS root:
49+
:: ------------------------------
50+
:: (vifm) (~/U/Projects) [22:18:42 02/20/23]
51+
>
52+
53+
```
54+
55+
### Features:
56+
57+
* Ascii-only but still pretty
58+
* Because there are so many bad terminal emulators out there.
59+
60+
* `Pure`-like:
61+
* Truncated Current Path Display (`~/U/P/shell.async-goprompt`)
62+
* last command duration (`9m30s`)
63+
* last command exit status (`[130]`)
64+
* makes debugging shell scripts and `test` commands that much easier
65+
* Vim Mode indicator support
66+
* (`>`) - default (insert mode)
67+
* (`>`) - normal (command edit mode)
68+
* SSH / Remote process detection
69+
70+
* Prompt Query State:
71+
* (`:?`) Prompt Query Ongoing
72+
* (`::`) Prompt Query Finished
73+
* (`:x`) Prompt Query Timeout or Failed
74+
75+
* Current Date Display (`[22:00:18 02/20/23]`)
76+
* Parent Process name (to see when you are in a nested session like in VIFM) (`(vifm)`)
77+
78+
* VCS: Git (`{git:main:&:[+1:-0]}`)
79+
* **[works fast even in a gigantic sluggish monorepo]**
80+
* Current Branch (`main`)
81+
* Index/Worktree Dirty Status (`&`)
82+
* Rebase Detection (`:rebase`)
83+
* Lag Behind Remote (`[+1:-0]`)
84+
* Number of unpublished commits (`+1`)
85+
* Number of new remote commits (`-0`)
86+
87+
* VCS: Git+Stacked Git (`{stg:readme:1/2}`)
88+
* Current Patch (`readme`)
89+
* Patch stack size and location in the stack (`1/2`)
90+
* Metadata out of sync alert (`stg` badge will turn red)
91+
92+
* VCS: Sappling (new VCS from Facebook) (`{spl:feature1:&}`)
93+
* Current Active Bookmark (`feature1`)
94+
* Worktree Dirty status (`&`)
95+
96+
## Technology / Implementation Details
697

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

9100
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.
10101

102+
### Protocol
11103

12-
![Demo Of GoPrompt With ZLE](./assets/Kapture%202022-07-26%20at%2010.45.33.gif "Capture")
104+
The `query` command output must adhere to a line protocol to be effective in making use of ZLE File Descriptor handler.
105+
106+
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)
107+
108+
First of all the protocol is **new line** and **tab** delimited, where each line takes the following form:
109+
```
110+
$KEY1<tab char>$VALUE1
111+
$KEY2<tab char>$VALUE2
112+
```
113+
114+
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.
115+
116+
Each empty line triggers a prompt refresh, kind of like a `sync` singal.
117+
```
118+
$KEY1<tab char>$VALUE1
119+
$KEY2<tab char>$VALUE2
120+
<empty>
121+
$KEY3<tab char>$VALUE3
122+
$KEY4<tab char>$VALUE4
123+
```
124+
125+
126+
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.
127+
128+
Upon every `sync` signal renderer gets a newline concatentated list of Key Value Lines on its `STDIN`, and produces the actual prompt.
129+
130+
### Renderer
131+
132+
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.
133+
134+
Overall the renderer is a bit like a pure `React` component `render` function.
13135

14136
## Reference
15137

16138
You can find the ZSH/ZLE integration in:
17139

18140
* [prompt_asynczle_setup.zsh](./plugin/zsh/prompt_asynczle_setup.zsh)
19141

20-
And the main POC query/rendering logic is implemented in GO
142+
And the main query/rendering logic is implemented in GO
21143

22144
* [goprompt](./cmd/goprompt)
23145

0 commit comments

Comments
 (0)