Skip to content

Displays a compact color-coded git status, git branch, the lastest commit log, and the number of stashes inside your shell prompt.

Notifications You must be signed in to change notification settings

Dosx001/GitPrompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitPrompt

GitPrompt is multi-threaded C++ program design to display all relevant Git information inside your shell prompt, such as Git status.

I designed GitPrompt to work only on Linux. Keeps GitPrompt simple and fast. I'm assuming most developers are working on Linux if not come join the fun! But if there is enough demand I could make a Windows or Mac version.

Table of Contents

What does GitPrompt do?

Git Status

Prints and color codes every file inside the shell prompt. To see all 20 different color codes checkout Git Status Color Codes

Latest Git Commit Log

Shows the latest commit log of the current branch in gray text. Imgur

Git Branch

Shows the current git branch in the red background. Imgur

Git Stash

Shows the number of git stashes in the purple background. Note if the number of stashes is zero then this section will not print. Imgur

Git Rebase

Shows if your currently rebasing in the green background. Imgur

Git Merge

Shows if your are currently merging and with which branch. Imgur

Git Status Color Codes

Normal

Status Color
Untracked File git
Modified File git
Staged Modified File git
Modified Staged Modified File git
Deleted Staged Modified File git
Deleted File git
Staged Deleted File git
New File git
Modified New File git
Deleted New File git
Rename File git
Modified Rename File git
Deleted Rename File git

Merge Conflicts

Status Color
Modified File git
New File(Self) git
New File(Them) git
New File(Both) git
Deleted File(Self) git
Deleted File(Them) git
Deleted File(Both) git

Installation

From Source

git clone git@github.com:Dosx001/GitPrompt.git
cd GitPrompt
cmake CMakeLists.txt
make
sudo ln -s /PATH/TO/DIR/GitPrompt/bin/gitprompt /usr/bin/git-prompt

Arch Linux

paru -S git-prompt
yay -S git-prompt

Nerd Font

You might see weird symbols like this one . Just install Nerd Font.

git clone https://github.com/sgolovine/nerdfont-patcher.git
cd nerdfont-patcher
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:fontforge/fontforge
sudo apt-get update -y
sudo apt-get install -y fontforge
fontforge -script font-patcher /PATH/TO/YOUR/FAVORITE/FONT/FontName.ttf -c

Install your new font and change your terminal font to the new font.

Setup

Bash

Just put "$(git-prompt)" anywhere inside of PS1.

export PS1="\u@\h \$(git-prompt)\[\e[00m\]\n\W\\$ "

My personal bash prompt.

export PS1="\[\e[92m\]\u@\h \$(git-prompt)\n\[\e[32;44m\] \W \[\e[0;34m\]\[\e[0m\]"

Zsh

Just add these lines inside your .zshrc and you're set.

_prompt() {
    git-prompt
}

autoload -U add-zsh-hook
add-zsh-hook precmd _prompt

My personal zsh prompt.

_prompt() {
    if [[ -e `git rev-parse --git-dir 2> /dev/null` ]]; then
        echo -n "$fg[green]`whoami`@`cat /proc/sys/kernel/hostname` "
    else
        echo "$fg[green]`whoami`@`cat /proc/sys/kernel/hostname`"
    fi
    git-prompt
}

autoload -U add-zsh-hook
add-zsh-hook precmd _prompt

autoload -U colors && colors
PROMPT="%{$fg[green]$bg[blue]%} %1d %{$reset_color%}%{$fg[blue]%}%{$reset_color%}"

About

Displays a compact color-coded git status, git branch, the lastest commit log, and the number of stashes inside your shell prompt.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published