Enhanced Git Prompt for ZSH

November 6, 2023 · View on GitHub

A Zsh plugin written in bash which provides a more granular information about git repositories.

The Enhanced Git Prompt can show information about the current branch/hash name, it can tell if there is an upstream branch being tracked and the difference in commits between the upstream. When there is any stash entries a flag will also be shown.

The prompt can also provide information about the status of a repository. It will display the amount of modified and deleted files and the ones which are staged, untracked and conflicted.

Enhanced Prompt

Branch Tracking Symbols

SymbolColorMeaning
redcurrent branch has no upstream
↑ncyanahead of upstream by n commits
↓nyellowbehind of upstream by n commits
yellowthere is a stash entry

Repository Status Symbols

SymbolColorMeaning
+nbluethere are n modified files
-nredthere are n deleted files
●nyellowthere are n staged files
●ncyanthere are n untracked files
!nredthere are n conflicted files
greenrepository is clean

Examples

This first example displays a repository current on develop branch with 4 modified, 3 deleted, 2 staged files and one untracked change.

Example01

On the example below, there is a clean repository on the feature branch with no upstream branch being tracked.

Example02

On the last example, there is a clean repository on the feature branch ahead of the upstream branch by 1 commit and behind by 2.

Example03

Installation

  1. Create a new folder called git-prompt-enhanced inside ~/.oh-my-zsh/custom/plugins.
  2. Copy the git-prompt-enhanced.plugin.zsh script to the new folder.
  3. Add the plugin git-prompt-enhanced to your plugins variable on your .zshrc file.
    • plugins=( ... git-prompt-enhanced )

Customization

Add Section