Crates.io | pretty-git-prompt |
lib.rs | pretty-git-prompt |
version | 0.2.2 |
source | src |
created_at | 2018-01-27 11:32:03.48843 |
updated_at | 2024-03-13 14:39:38.249003 |
description | Your current git repository information inside a beautiful shell prompt. |
homepage | https://github.com/TomasTomecek/pretty-git-prompt |
repository | https://github.com/TomasTomecek/pretty-git-prompt |
max_upload_size | |
id | 48503 |
size | 662,323 |
Your current git repository information inside a beautiful shell prompt.
Features:
You are able to display values such as:
merge
conflict, interactive rebase
, ...)You can track divergence against arbitrary branches.
Every value in output can be fully configured via a config file.
Sample configuration files feature colors.
The tool supports zsh
and bash
.
pretty-git-prompt is written in Rust programming language and is delivered as a single, statically-linked binary.
The tool is ready to use.
Very easily! You don't need to install pretty-git-prompt if you just want to see it in action. There is a make target which launches docker container with whole environment set up.
It just takes some time to prepare the environment (create build environment, compile the tool, run the demo).
Just clone this git repository
$ git clone https://github.com/TomasTomecek/pretty-git-prompt
and run...
$ make zsh-demo
And this is what you should see:
This is an interactive shell, so you can play with it.
In case you want to see the tool in bash shell:
$ make bash-demo
This demo is one of the ways I verify that the tool works correctly.
If you want to add pretty-git-prompt inside your shell, this section contains information how to do that.
pretty-git-prompt
binaryGet the binary via latest GitHub release.
For a linux distrubution:
$ curl -O https://github.com/TomasTomecek/pretty-git-prompt/releases/download/0.2.0/pretty-git-prompt-0.2.0-x86_64-unknown-linux-gnu
Or for MacOS:
$ curl -O https://github.com/TomasTomecek/pretty-git-prompt/releases/download/0.2.0/pretty-git-prompt-0.2.0-x86_64-apple-darwin
$ make build
As stated inside demo section above, this takes some time.
If you have rust compiler and cargo available on your system, you can compile the tool without using a container:
$ make exec-stable-build
The binary is then available on this path:
$ ls -lha target/release/pretty-git-prompt
-rwxr-xr-x 2 user group 1.7M May 9 21:37 target/release/pretty-git-prompt
Before digging into .bashrc
and .zshrc
, please make sure that binary
pretty-git-prompt
is placed on your $PATH
:
$ pretty-git-prompt
master|✚1Δ1
This seems to be the minimal config required:
export LC_ALL=en_US.UTF-8
# Load colors.
autoload -U colors
colors
# Allow for functions in the prompt.
setopt PROMPT_SUBST
RPROMPT='\$(pretty-git-prompt)'
Just put it inside your ~/.zshrc
and try it out.
You should paste this inside your ~/.bashrc
:
pretty_prompt() { PS1="$(pretty-git-prompt)\n\$ "; }
export PROMPT_COMMAND="pretty_prompt ; $PROMPT_COMMAND"
For more info about the presented solution, please read these superuser.com and stackoverflow threads.
If you encounter a problem, you may run the tool with verbose output to help you resolve the issue:
$ pretty-git-prompt --debug
Debug messages are enabled.
This is not a git repository: Error { code: -3, klass: 6, message: "could not find repository from \'.\'" }
The configuration is documented inside default config file. Therefore it's not explicitly written down here. You can obtain it via:
$ pretty-git-prompt create-default-config
Configuration file created at "/home/you/.config/pretty-git-prompt.yml"
This repository contains also configuration for bash and zsh with colors:
In case anything is not clear from the comments inside the config files, please open a new issue.
This is an open source project. I don't guarantee any support. Everything is best effort.
This project builds upon several principles:
If you encounter any issue, please submit it! I will take a look. The best thing to do in the meanwhile is to try fixing it yourself.
The whole development environment should be trivial to setup, even run tests.
All you need is docker engine running and make
.
First you need to build container image with rust and all dependencies inside:
$ make nightly-environment
This is using latest nightly rust. The nightly is used because of clippy.
And then just make sure all tests are passing and you are not introducing any new warnings:
$ make test
If any of the two make
invocations above doesn't work for you, please open an issue.
This tool is heavily inspired by zsh-git-prompt. At some point I realized, I wanted a more powerful tool so I wrote pretty-git-prompt.