Home

Awesome

Clover

🍀 a configurable theme for zsh, inspired by zeta-zsh-theme and pure.

screenshot

Installation

oh-my-zsh

clone this repo into $ZSH_CUSTOM:

cd ${ZSH_CUSTOM:-"~/.oh-my-zsh/custom"}/themes
git clone git@github.com:tzing/clover.zsh-theme.git clover

then change the theme:

ZSH_THEME="clover/clover"

zinit

zinit light tzing/clover.zsh-theme

Manual

clone this repo to somewhere you like:

git clone git@github.com:tzing/clover.zsh-theme.git <PATH>

and source the main script in your .zshrc

source <PATH>/clover.zsh-theme

Configurations

This theme reads the configurations from zstyle. All context name must be prefixed with :prompt:clover:. Styles are always configurable, and for some components you could also customized the symbols.

Here's a disgram that shows context names:

   ┌---------------------------------------------------------------------- user
   |    ┌----------------------------------------------------------------- host
   |    |         ┌------------------------------------------------------- path
   |    |         |                   ┌----------------------------------- vcs:branch
   |    |         |                   |    ┌------------------------------ vcs:status (read details below)
   |    |         |                   |    |          ┌------------------- execution-time
   |    |         |                   |    |          |    ┌-------------- current-time
#  user@hostname: ~/clover.zsh-theme <main ✔⇡>        10s (12:00:00 +0800)
(.venv) 🍀
 |      └----------------------------------------------------------------- prompt
 └------------------------------------------------------------------------ virtualenv

[!NOTE]

VCS information (:prompt:clover:vcs:*) are evaluated in background process, which is forked in first precmd run. Runtime zstyle settings will not take effect. But you could still change the style in .zshrc.

Styles

Run zstyle command with the key style. And the value could be the visual effect expresssion in zsh prompt expansion.

An example of setting the path to bold cyan:

zstyle :prompt:clover:path style '%B%F{cyan}'

Symbols

Use key symbol for customization.

For example, setting default prompt symbol to $:

zstyle :prompt:clover:prompt:default symbol '$'

Contexts and default styles

context nameusagedefault styledefault symbol
current-timeCurrent timeblue
execution-timeLast execution time242
host:containerHost name when it is inside a containerbold white text in magenta bg
host:defaultHost namebold cyan
host:remoteHost name when it is remote sessionbold white text in blue bg
pathCurrent pathbold yellow
prompt:defaultPrompt colorgreen🍀
prompt:failPrompt color when last run failedred🔥
user:defaultUser namebold green
user:rootUser name when current user is rootbold green
vcs:actionCurrent action in VCSred
vcs:branchCurrent branch namebold blue
vcs:status:ahead[Git only] Current branch is ahead of remotecyan
vcs:status:behind[Git only] Current branch is behind of remotemagenta
vcs:status:clean[Git only] Work tree is cleangreen
vcs:status:diverge[Git only] Diverged changes foundred
vcs:status:stagedFound staged changes in current repogreen
vcs:status:unstagedFound unstaged changes in current repomagenta
vcs:status:untracked[Git only] Found untracked file242?
virtualenvPython virtualenv prompt prefix242

Others

There are some other settings could be changed through zstyle too:

context namekeyusagedefault
current-timeformatFormat for current time. See strftime(3) for more details.%H:%M:%S %z
execution-timemin-display-secondOnly show execution time when last run is longer than this time.5