Skip to content

geometry is a minimal, fully customizable and composable zsh prompt theme

License

Notifications You must be signed in to change notification settings

geometry-zsh/geometry

Repository files navigation

geometry

geometry logo by @MarioRicalde

a minimalistic, fully customizable zsh prompt theme

geometry starts small, with reasonable defaults, and allows you to customize it at your own will. It can be as simple or complex as you like.

If you have a question, suggestion, or request please open an issue and be sure to check out our contribution guide

What it does

All geometry does is run simple functions to customize the left and right prompts.

We bundle a few useful functions to start with, that can:

  • give you a custom colored prompt symbol
  • change the prompt symbol color according to the last command exit status
  • make the prompt symbol color change with your hostname
  • display current git branch, state and time since latest commit
  • tell you whether you need to pull, push or if you're mid-rebase
  • display the number of conflicting files and the total number of conflicts
  • display if there is a stash
  • display the running time of long-running commands
  • set the terminal title to current command and directory
  • make you the coolest hacker in the whole Starbucks

The right side prompt prints asynchronously, so you know it's going to be fast™.

Geometry also has a secondary prompt that shows up when pressing enter with an empty command, which you can configure with GEOMETRY_INFO.

Installing

tool add to .zshrc
zr zr geometry-zsh/geometry
zplug zplug "geometry-zsh/geometry"
antigen antigen theme geometry-zsh/geometry
Homebrew brew install geometry
manually source geometry/geometry.zsh (after git clone https://github.com/geometry-zsh/geometry)

Functions

showing prompt customization with new function

Geometry displays output in several places. The output displayed in each location is determined by the plugins configured for that location. These are the supported locations, along with the environment variable used to configure each one.

Variable Name Text display location
GEOMETRY_PROMPT Text shown to the left of the cursor
GEOMETRY_RPROMPT Text shown at the right edge of the terminal
GEOMETRY_INFO Text shown after pressing enter with no input
GEOMETRY_TITLE Text shown in the terminal title
GEOMETRY_CMDTITLE Text shown in the terminal title when a command is run

To customize the prompt, add any function to the list of functions for the desired display location:

GEOMETRY_PROMPT=(geometry_status geometry_path) # redefine left prompt
GEOMETRY_RPROMPT+=(geometry_exec_time pwd)      # append exec_time and pwd right prompt
GEOMETRY_TITLE=(geometry_node)

Most of these functions only show up if it makes sense to (for example, geometry_git only shows up if in a git repository).

Please check out and share third-party functions on our functions wiki page

For more details on how to create a function, check out our contribution guide

If you prefer a two-line prompt, try GEOMETRY_PROMPT+=(geometry_newline)

Configuration

You can configure everything in geometry by defining a variable.

The default configuration tries to balance the theme to be both lightweight and contain useful features.

Here we highlight some of the more commonly customized variables, but to see all of them, look in the function definitions inside the functions directory.

general

GEOMETRY_SEPARATOR=" "    # use ' ' to separate function output

geometry_status

GEOMETRY_STATUS_SYMBOL=""             # default prompt symbol
GEOMETRY_STATUS_SYMBOL_ERROR=""       # displayed when exit value is != 0
GEOMETRY_STATUS_COLOR_ERROR="magenta"  # prompt symbol color when exit value is != 0
GEOMETRY_STATUS_COLOR="default"        # prompt symbol color
GEOMETRY_STATUS_COLOR_ROOT="red"       # root prompt symbol color

geometry_exitcode

This renders the exit code of the previous function if it is not success.

GEOMETRY_EXITCODE_COLOR="red" # exit code color

geometry_git

The git function is one of the most developed plugins in geometry. We recommend installing rg or ag for the best performance with geometry_git. If you want to customize what is shown, instead of using geometry_git, feel free to use the helper functions geometry_git_{symbol, branch, conflicts, time, stashes & status}. You may also want to use geometry::git_wrapper to have the nice :: joining.

GEOMETRY_GIT_SYMBOL_REBASE="\uE0A0" # set the default rebase symbol to the powerline symbol 
GEOMETRY_GIT_SYMBOL_STASHES=x       # change the git stash indicator to `x`
GEOMETRY_GIT_COLOR_STASHES=blue     # change the git stash color to blue
GEOMETRY_GIT_GREP=ack               # define which grep-like tool to use (By default it looks for rg, ag and finally grep)
GEOMETRY_GIT_NO_COMMITS_MESSAGE=""  # hide the 'no commits' message in new repositories
GEOMETRY_GIT_TIME_DETAILED=true     # show full time (e.g. `12h 30m 53s`) instead of the coarsest interval (e.g. `12h`)

picture of git features

Hostname based colors

Geometry provides a generic function (geometry::hostcolor) for setting any color based on hostname. The color is calculated as the sum of each character converted to an integer. For example the hostname 'abc' generates a value of 294.

By default the colors 1-9 and 17-230 are used as colors depending on what the environment supports. The calculated value is then modded by the size of the color list to choose a value. This value will be consistent given the same hostname.

These colors can be overridden by setting variables.

GEOMETRY_HOST_COLORS=({1..7})  # Only use the colors 1-7
GEOMETRY_HOST_COLOR=4          # Override the color for a specific host.

colorize

Thanks

geometry is maintained by frm, desyncr and jedahan.

Thank you MarioRicalde for the lovely logos and branding.

A big thank you to the dozens of additional contributors.