Giter Club home page Giter Club logo

geometry's Introduction

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.

geometry's People

Contributors

alxbl avatar castellanprime avatar cnguy avatar coteeq avatar crasx avatar desyncr avatar diogoazevedos avatar duncanbeevers avatar ev-agelos avatar frm avatar frmendes avatar hanslovsky avatar itsxaos avatar jedahan avatar keelan542 avatar kguthrie avatar konsonanz avatar kyounger avatar lurst avatar magejohn avatar marioricalde avatar michcioperz avatar mihaiolteanu avatar olegtarassov avatar plantevodu avatar sephvelut avatar shridharmanvi avatar thomaso-mirodin avatar wuvs avatar zapashcanon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

geometry's Issues

config option to render the prompt on one line (feature)

Is there any particular reason the prompt always adds an extra line? I was wondering if we could add an option to remove that, I found if I changed

prompt_geometry_render() {
  PROMPT="
 %(?.$GEOMETRY_PROMPT.$GEOMETRY_EXIT_VALUE) %F{$GEOMETRY_COLOR_DIR}%3~%f "

  PROMPT2=" $GEOMETRY_SYMBOL_RPROMPT "
  RPROMPT="$(prompt_geometry_git_info)%{$reset_color%}"
}

to

prompt_geometry_render() {
  PROMPT="%(?.$GEOMETRY_PROMPT.$GEOMETRY_EXIT_VALUE) %F{$GEOMETRY_COLOR_DIR}%3~%f "
  PROMPT2=" $GEOMETRY_SYMBOL_RPROMPT "
  RPROMPT="$(prompt_geometry_git_info)%{$reset_color%}"
}

and i get a single line

image

unless you think this would break anything I'm happy to submit a PR w/ this as a feature/optoin

Add Node/yarn version plugin

Create built-in plugin (in the lines of virtualenv and docker_machine) for node and npm version prompt.

Prompt should look something like:

⬡ v6.9.2 (3.10.9)

npms start up time is quite noticeable so version information should be cached in the setup phrase, in fact, this should be done for node and npm.

This is a great opportunity for anyone interested in contributing.

Gracefully handle `--ignore-submodules` flag missing in git 1.7.1 and below

--ignore-submodules flag was introduced in git 1.7.2. If geometry is used with this git version it throws an error:

~/geometry error: unknown option `ignore-submodules'
usage: git status [options] [--] <filepattern>...

    -v, --verbose         be verbose
    -s, --short           show status concisely
    --porcelain           show porcelain output format
    -z, --null            terminate entries with NUL
    -u, --untracked-files[=<mode>]
                          show untracked files, optional modes: all, normal, no. (Default: all)

This is almost a non-issue as git 1.7.1 was released in 2010, but I stumbled with this issue on a CentOS 6 machine.

Cannot configure geometry for single line usage

I was looking for a way to configure geometry to a single line prompt, so I tried setting GEOMETRY_PROMPT_PREFIX="" but this does not seem to work. I randombly fell on #102 and specifically on this line. I have very limited zsh knowledge but I guess that this defines GEOMETRY_PROMPT_PREFIX to be $\n if it is not set.

By adding it in a configuration file with an empty setting, I guess it is treated as "not set" so it defaults to a new line.

Is it possible to override this somehow and get a single line prompt?

Tab completion problem

I am having a problem using this theme when I try to tab complete

so it's like
▲ .oh-my-zsh/custom/themes ls
and after tab completion it becomes
▲ .oh-my-zsh/custom/themesls

I tried to modify the theme but failed. Really can't figure out where the problem is

Set title doesn't work as expected

When executing a long-running command the terminal title is set to "$COMMAND @ $CURR_DIR". Should it be the running command.

screen shot 2016-12-01 at 6 02 19 pm

Should be an easy fix for anybody interested in contributing.

Add Ruby/rvm version plugin

Similar to #57 create a plugin for ruby/rvm version information prompt.

Use rvm/rbenv if available. Display in the following format:

 ◆ 2.3.3 (1.27.0)

Cache version information in the setup phrase.

This is a great opportunity for anyone interested in contributing.

Remove "enabled" flag for plugins

Some plugins, such as docker machine, have an enabled variable. If the plugin is loaded, it should be considered enabled, otherwise the user wouldn't have added it to the plugin list.

It's also not intuitive having to add the plugin to a plugin list and setting an environment variable.

Option to add custom prefix/postfix to PROMPT

I'd like to define my own indicators that will be included in PROMPT. I can easily create a function or variable to return indicator string, but I miss is a proper way to inject it into geometry PROMPT.

RFC: Plugin architecture

There are lots of tools that can be added to the prompt, they are useful for some but not generally useful for everyone, naturally. This causes the code to grow large and maintenance becomes a problem. This will become an issue as more prompts are added.

To be able to manage this issue I propose to turn most informative prompts (git, virtualenv, python, etc) into a separate file that can be loaded at runtime. This will keep separate the base prompt from the informative prompts, making maintenance a bit easier. Also performance-wise seems reasonable to keep unloaded unused prompts.

This structure will also provide the ability to create custom -user made- prompts, outside the geometry code base.

Implementation will require to establish a common interface for the prompts (function and variable names) as well as a globally available array to register a given plugins/prompt. Similar to https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md

Thoughts?

Edit: Probably Fixes #24

Git prompt issues with Prezto

BRACE_CCL option set by prezto's environment module causes:

Fatal error ambiguous argument @u

By removing { and } from the commands.

Lag and high CPU usage on large repositories holding enter-key

On this particular scenario, where the user holds the enter-key and the current directory is a huge repository, geometry (async library, in fact) may consume a lot of CPU and for this reason the prompt may "lag" and seem "slow".

I attribute the high CPU usage to the exec, kill, and re-exec of git subprocesses to print the git built-in plugin.

We could solve this by performing a small cache (1 sec, half a sec) of rprompt. Any other idea? Suggestion?

Errors showing on new session

After updating zplug and my plugins (including geometry) I began receiving the following messages, everytime I start a new session.

$ zsh
Error: Plugin exec_time already registered.
Error: Plugin git already registered.
Error: Plugin hg already registered.

How can this be fixed?

Random hostname colouring range

As of now it's not really that much random.

There are a lot of recurrent colors (purple, blue, light blue). Might have to do with my own setup which currently is Base16 Tomorrow Night.

However there seem to be some colors that are missing out, mainly to try and avoid conflicts with the red symbol used when a command has a non-zero exit.

Zsh theme development processes

A bit offtopic but I'm having trouble with developing for this plugin, since my process currently is just to change the repo dir inside ~/.antigen/repos/, running antigen update and then opening a new terminal and checking if it worked. I'm using an absolute dir path in my ~/.zshrc but antigen update doesn't seem to be tracking changes there. Do you have a better way of doing this?

Spaces before git plugin's branch name

There are a few empty spaces before git branch name. There should be a single space between the plugin outputs (in this case exec_time and git).

screen shot 2016-12-13 at 1 15 29 pm

For anyone interested in their first PR.

`exec_time` built-in plugin keeps on being displayed

The exec_time built-in plugin shows a strange behavior after being displayed once. It may keep being show whether a command is executed or not.

Steps to reproduce:

  • Launch terminal
  • Wait at least 5 seconds
  • Press Enter key

Expected behavior:

  • No exec_time plugin is shown

Shown behavior:

  • exec_time is shown (8s, 9s, etc)

prompt_geometry_set_cmd_title: backticks and $() get evaluated twice

Over at oh-my-zsh we just confirmed the geometry theme to be responsible for the double evaluation of commands within backticks and $():

$ echo echo doh >> doh
$ cat doh
doh
doh

The same happens with $(). mcornella was able to trace it to:

prompt_geometry_set_cmd_title () {
prompt_geometry_print_title "${2} @ %m"
}

When I set that function to {}, the problem disappears.

prompt_geometry_render:1: = not found

I am using zplug to manage my plugins, since the update from #13, I now get this error:

prompt_geometry_render:1: = not found

I have updated, reloaded my terminal, reloaded zsh and as a last resort re-installed geometry.

Any thoughts? I looked through the code but my understanding is very primitive. Thanks

Variables that I am using:

PROMPT_GEOMETRY_GIT_TIME=false
GEOMETRY_COLOR_GIT_DIRTY=9
GEOMETRY_COLOR_GIT_BRANCH=6
GEOMETRY_COLOR_EXIT_VALUE=9
PROMPT_GEOMETRY_GIT_CONFLICTS=true
GEOMETRY_SYMBOL_EXIT_VALUE="▲"

Aliased commands may break geometry

As per #59. Aliased commands may break/change geometry inner workings.

Avoid this with a similar approach to zsh-users/zsh-syntax-highlighting#390:

At the top:

# Save aliases into a variable and remove/unalias everything
zsh_highlight__aliases=`alias -L`
builtin unalias -m '*'

At the bottom:

# Restore aliases & kill global variable
eval "$zsh_highlight__aliases"
builtin unset zsh_highlight__aliases

`_git_remote_check:5: = not found`

Hi there, I really like this minimal theme. There's just a small annoyance, whenever I cd to a directory with a git repo, it outputs:

_git_remote_check:5: = not found

Option to disable RPROMPT

Having RPROMPT when running a subshell in midnight commander produces all kind of weirdness. I used to disable it completely under such condition. All I need is an option in geometry to do so. Probably I can hack it around without changing the geometry, but messing with precmd hooks isn't a sane way to maintain it.

Async support for git info

It seems like there is a big delay getting the git information, especially for large repositories. There are some small optimizations we can do with git log -1 everywhere but maybe looking at pure and other prompts that use async we can get a pty to render the git portion.

Left prompt customization

  • Modify prompt to make use of plugins
  • Be able to configure plugins for rprompt as well as prompt.
  • Evaluate which customization can be added

Virtualenv support

Hi @frmendes, I found this theme recently and am loving it, but it's missing Python's virtualenv support, if I send a PR, are you interested in merging such a feature?

Making geometry look like it is shown in the example images

In the example images, the colors and other configuration options are different from the default configuration geometry has. Is it possible for the exact configuration of the example to be explained somewhere, or at least some of the color choices? It looks awesome.

Add section with user submitted plugins

To give visibility and kick start a plugin ecosystem.

Meanwhile most custom plugins are rather too specific for publishing there is still a place for plugins for 'svn', for example.

Thoughts you guys?

Extra space when disabling git commit time

Recently been using this theme and loving it, this is extremely nit picky, but for such an aesthetic theme it stands out!

If you disable the git time, there's a gap between the spacing where it used to be:

Is it possible to make the spacing consistent? Thanks

Complete config for custom separator

Update default plugins to make use of GEOMETRY_PLUGIN_SEPARATOR to separate prompt blocks.

Some plugins such as git use a hardcoded string as separator (ex. ::). Review if it's necessary to change it for each plugin or just some of them.

git_conflicts issue since zplug 2.3.1

Hi,

Updated to zplug 2.3.1, and since then have had lots of issues with zsh, there is also this issue, where the theme is not displayed, but this error keeps appearing:

prompt_geometry_git_conflicts:[:10: integer expression expected: 1\n1

I have an issue posted (here, for some more information)[https://github.com/zplug/zplug/issues/268]

Do you know if this is anything caused on your end, or a symptom of a larger issue?

Clarify plugins used in screenshots

Some users may assume that syntax highlighting will be enabled with the theme (command colouring) - at least I got asked once.

So it may be useful to add a note explaining which plugins are used.

AFAIK there is only zsh-users/zsh-syntax-highlighting plugin installed in the screenshots.

Edit: Other thing to add would be the terminal and rupa/z plugin.

branch parse error

I seem ti be getting a parse error when im changing from branch or fetch. This ends up to not showing the branch name in the promt anymore.

_git_branch:4: parse error: condition expected: 1
__gitcomp_nl:compset:5: can only be called from completion function
__gitcomp_nl:compadd:6: can only be called from completion function

msbzj
screen shot 2016-05-23 at 11 17 57

I'm using iTerm on OS X El Capitan v10.11.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.