A fast, customisable, pure-shell, asynchronous Pijul prompt for Zsh.
It is heavily inspired by and essentially a fork of Wolfgang Popp's git-prompt.zsh with the Awk parser updated for Pijul. In turn, git-prompt.zsh is heavily inspired by Olivier Verdier's zsh-git-prompt and very similar to the "Informative VCS" prompt of fish shell.
Most of the credit should go to them đ.
The structure of the prompt (in the default configuration) is the following:
[<channel><remote>|<local_status>]
channel
: Name of the current channel.remote
: Path of the remote if it exists.
Must be enabled explicitly (see Enable remote info).local_status
:
â
: repository is cleanân
: there are n
changed files+n
: there are n
added filesân
: there are n
deleted filesân
: there are n
resurrected zombiesân
: there are n
solved conflictsĂn
: there are n
unsolved conflictsâŚn
: there are n
untracked filesClone this repo or download the pijul-prompt.zsh file. Then source it in your .zshrc
. For example:
mkdir -p ~/.zsh
pijul clone https://nest.pijul.com/ryanbooker/pijul-prompt.zsh ~/.zsh/pijul-prompt.zsh
echo "source ~/.zsh/pijul-prompt.zsh/pijul-prompt.zsh" >> .zshrc
# Optional: install an example configuration
echo "source ~/.zsh/pijul-prompt.zsh/examples/default.zsh" >> .zshrc
Either install the default prompt (see Examples section below) with
# Installs the "default" example
zplug "ryanbooker/pijul-prompt.zsh"
or choose an example prompt with
# Installs the "multiline" example
zplug "ryanbooker/pijul-prompt.zsh", use:"{pijul-prompt.zsh,examples/default.zsh}"
zplugin ice atload'!_zsh_pijul_prompt_precmd_hook' lucid
zplugin load ryanbooker/pijul-prompt.zsh
Note that this method does not work if you want to disable the asynchronous rendering.
Unlike other popular prompts this prompt does not use promptinit
, which gives you the flexibility to build your own prompt from scratch. You can build a custom prompt by setting the PROMPT
variable in your .zshrc
after souring the pijul-prompt.zsh
. And you should use '$(pijul_prompt)'
in your PROMPT
to get the Prijul prompt. You must set your PROMPT
with single quotes, not double quotes, otherwise the Pijul prompt will not update properly. Some example PROMPT
configurations are given below. You can find more information on how to configure the PROMPT
in Zsh's online documentation or the zshmisc
manpage, section "SIMPLE PROMPT ESCAPES".
See examples/README.md for more details.
The appearance of the prompt can be adjusted by changing the variables that start with ZSH_THEME_PIJUL_PROMPT_
.
You can preview your configuration by setting the ZSH_THEME_PIJUL_PROMPT_*
variables in a running shell. But remember to save them in your .zshrc
after you tweaked them to your liking!
Example snippet from .zshrc
:
ZSH_THEME_PIJUL_PROMPT_PREFIX="["
ZSH_THEME_PIJUL_PROMPT_SUFFIX="] "
ZSH_THEME_PIJUL_PROMPT_SEPARATOR="|"
ZSH_THEME_PIJUL_PROMPT_CHANNEL="%{$fg_bold[magenta]%}"
ZSH_THEME_PIJUL_PROMPT_REMOTE_SYMBOL="%{$fg_bold[yellow]%}âł "
ZSH_THEME_PIJUL_PROMPT_REMOTE_NO_TRACKING=""
ZSH_THEME_PIJUL_PROMPT_REMOTE_PREFIX="%{$fg[red]%}(%{$fg[yellow]%}"
ZSH_THEME_PIJUL_PROMPT_REMOTE_SUFFIX="%{$fg[red]%})"
ZSH_THEME_PIJUL_PROMPT_CHANGED="%{$fg[blue]%}â"
ZSH_THEME_PIJUL_PROMPT_ADDED="%{$fg[green]%}+"
ZSH_THEME_PIJUL_PROMPT_REMOVED="%{$fg[red]%}â"
ZSH_THEME_PIJUL_PROMPT_RESURRECTED="â"
ZSH_THEME_PIJUL_PROMPT_SOLVED="%{$fg[magenta]%}â"
ZSH_THEME_PIJUL_PROMPT_UNSOLVED="%{$fg[yellow]%}Ă"
ZSH_THEME_PIJUL_PROMPT_UNTRACKED="âŚ"
ZSH_THEME_PIJUL_PROMPT_CLEAN="%{$fg_bold[green]%}â"
source path/to/pijul-prompt.zsh
The prompt will show information about the remote, if ZSH_PIJUL_PROMPT_SHOW_REMOTE
is set to full
or symbol
. The full
option will print the full remote path enclosed by ZSH_THEME_PIJUL_PROMPT_REMOTE_PREFIX
and ZSH_THEME_PIJUL_PROMPT_REMOTE_SUFFIX
. The symbol
option prints only ZSH_THEME_PIJUL_PROMPT_REMOTE_SYMBOL
.
Furthermore, a warning symbol can be configured through ZSH_THEME_PIJUL_PROMPT_REMOTE_NO_TRACKING
for the case where no remote is available. ZSH_THEME_PIJUL_PROMPT_REMOTE_NO_TRACKING
can be set independently of ZSH_PIJUL_PROMPT_SHOW_REMOTE
.
By default, the prompt will show counts for each item in the tracking status and local status sections. (See Prompt Structure for details about these sections.) However, you can disable the display of counts for either or both sections of the prompt using ZSH_PIJUL_PROMPT_SHOW_TRACKING_COUNTS
and ZSH_PIJUL_PROMPT_SHOW_LOCAL_COUNTS
. If you set these variables to anything other than 1
, then the symbols will be shown but not the counts.
For example, a prompt such as [master|â2]
will become [master|â]
instead.
Since the prompt is asynchronous by default, the Pijul status updates slightly delayed.
This has the benefit that the prompt will always be responsive even if the repository is huge and/or your disk is slow. But it also means that the old status will be displayed for some time. You can force the prompt to blank out instead of displaying a potentially outdated status, but be warned that this will probably increase flickering. Set the following variable in your .zshrc
to enable this behavior:
ZSH_PIJUL_PROMPT_FORCE_BLANK=1
If you are not happy with the asynchronous behavior, you can disable it altogether. But be warned that this can make your shell painfully slow if you enter large repositories or if your disk is slow. Set the following variable in your .zshrc
before sourcing the pijul-prompt.zsh
to enable this behavior.
ZSH_PIJUL_PROMPT_NO_ASYNC=1
ZSH_PIJUL_PROMPT_NO_ASYNC
cannot be adjusted in a running shell, but only in your .zshrc
.
Some awk implementations are faster than others. By default, the prompt checks for nawk and then mawk and then falls back to the system's default awk. You can override this behavior by setting ZSH_PIJUL_PROMPT_AWK_CMD
to the awk implementation of you liking before sourcing the pijul-prompt.zsh
. ZSH_PIJUL_PROMPT_AWK_CMD
cannot be adjusted in a running shell, but only in your .zshrc
.
To benchmark an awk implementation you can use the following command.
# This example tests the default awk. You should change it to something else.
time ZSH_PIJUL_PROMPT_AWK_CMD=awk zsh -f -c '
source path/to/pijul-prompt.zsh
for i in $(seq 1000); do
print -P $(_zsh_pijul_prompt_pijul_status)
done'
pijul_prompt
function, which you can use to build your own prompt.