explaingit

magicmonty/bash-git-prompt

6,919ShellAudience · developerComplexity · 1/5Setup · easy

TLDR

Shell script add-on that shows live Git status in your terminal prompt, branch name, changed files, ahead or behind the remote, so you never have to run a separate git status command.

Mindmap

mindmap
  root((bash-git-prompt))
    What it shows
      Branch name
      Changed files
      Ahead or behind
      Merge conflicts
    Installation
      Homebrew on Mac
      Clone and source
      Fish shell path
    Configuration
      Env variables
      Color themes
      Remote checking
    Shell support
      Bash
      Fish
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

See your current Git branch and dirty-file count at a glance in every terminal prompt without running extra commands

USE CASE 2

Configure the prompt to only activate inside Git repositories so non-repo directories stay uncluttered

USE CASE 3

Set up a color-themed Git prompt in Fish shell by copying the prompt file to the Fish functions directory

Tech stack

ShellBashFish

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Bash-git-prompt is a shell script add-on that modifies your terminal prompt to display live information about whichever Git repository you are currently working inside. Instead of a plain directory path, your prompt shows the branch name, how many files have been changed or staged, whether you are ahead of or behind the remote server, and other status details, all at a glance without running any separate commands. The project is a port of a similar prompt originally written for the Zsh shell, adapted here for Bash and also compatible with Fish. The prompt uses small symbols to represent different states: a checkmark when the repository is clean, a dot with a number for staged files, an X for merge conflicts, an upward arrow when you are ahead of the remote branch, a downward arrow when behind, and so on. The README shows several example prompts so you can see what these look like in practice. Installation can be done in a few ways. On Mac, Homebrew handles it with a single command. You can also clone the repository directly and add a short block of code to your shell configuration file pointing at the cloned script. Fish shell users have their own path through the fish config GUI or by copying the prompt file to the Fish functions directory. Once installed, behavior is controlled through environment variables set before sourcing the script. You can limit the prompt to only appear when inside a Git repository, control whether it automatically checks the remote for changes, show or hide untracked file counts, and switch between preset color themes. Several bundled themes are available, including one optimized for Solarized color schemes. A custom theme can be defined by overriding a single function in a separate file in your home directory.

Copy-paste prompts

Prompt 1
Show me the exact lines I need to add to my .bashrc to set up bash-git-prompt from a cloned repo, with the prompt showing only inside Git directories.
Prompt 2
I installed bash-git-prompt via Homebrew on Mac. What environment variables do I set to show untracked file counts and automatically check the remote for changes?
Prompt 3
How do I create a custom color theme for bash-git-prompt by overriding the theme function in a file in my home directory?
Prompt 4
My bash-git-prompt shows the wrong symbol for merge conflicts. What symbol does it use by default and how do I change it in a custom theme?
Open on GitHub → Explain another repo

← magicmonty on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.