# Bash Git Prompt for Linux
[](#)
[](#)
[](#)
[](./LICENSE)
A customizable Bash prompt with **five clean themes**, showing live Git repository status — branches, staged files, changes, stashes, and more.
Although designed for Ubuntu 24.04, it also runs smoothly on Fedora and most modern Linux distributions.
---
### Features
- Displays the current **Git branch** and live repository status
- Works across **five switchable themes** (changeable in real time)
- Shows **staged, changed, untracked, stashed, and remote** indicators
- Detects **clean vs. dirty** repository state instantly
- Compatible with Ubuntu, Fedora, and most POSIX-compatible shells
- Includes a **Nerd Font installer** for correct symbol rendering
---
### Prerequisites
Requires **DejaVuSansMono Nerd Font** for proper symbol display.
---
### Prompt Structure
The default prompt layout is:
```plaintext
```
Example output:
---
### Installation
Clone the repository:
```
git clone https://git.x-files.dk/bash/bash-git-prompt.git ~/.bash-git-prompt
```
Install fonts:
```
cd ~/.bash-git-prompt
./install-fonts.sh
```
Add the following to your .bashrc file:
```
# Git Prompt Start
if [ -f "$HOME/.bash-git-prompt/bash-git-prompt" ]; then
export GIT_PROMPT_THEME=1
source "$HOME/.bash-git-prompt/bash-git-prompt"
fi
# Git Prompt Stop
```
Reload your environment:
```
source ~/.bashrc
```
---
### Switching Themes
Change themes dynamically with:
```
gpchange
```
Example:
```
gpchange 3
```
This updates the theme instantly for your current session.
---
### Changing PS1
The script has been structured so modifying your PS1 is now simple and centralized.
To change the PS1 **inside a Git repository**, modify:
```
#
# PS1 custom for all themes inside a git repository
#
local PS1_CUSTOM='\[\e[0;32m\]\u@\h\[\e[0m\]'
```
To change the PS1 **outside a Git repository**, modify:
```
#
# PS1 custom for all themes outside a git repository
#
PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[38;5;178m\]\w\[\e[0m\] '"${PROMPT_CHAR} "
```
---
### Available Themes
Preview of all five themes (clean and dirty shown together for comparison):
Branch → Staged → Changed → Untracked → Stashed → Ahead → Behind → No-Remote → Conflict → Dirty → Clean
---
### Terminal Font Setup
Set your terminal to use:
```
DejaVuSansMono Nerd Font Mono
```
---
### Troubleshooting
**Symbols not showing correctly:**
Make sure your terminal uses *DejaVuSansMono Nerd Font Mono*.
Restart your terminal after installing fonts.
Log out and back in after installing fonts.
**Prompt not loading:**
Verify these lines exist and are correct in `~/.bashrc`:
```
# Git Prompt Start
if [ -f "$HOME/.bash-git-prompt/bash-git-prompt" ]; then
export GIT_PROMPT_THEME=1
source "$HOME/.bash-git-prompt/bash-git-prompt"
fi
# Git Prompt Stop
```
---
### FAQ
**Q:** Does this replace my default prompt entirely?
**A:** No — the Git-aware segment only appears when your current directory is inside a **Git repository**.
**Q:** Can I create my own theme?
**A:** Absolutely. Each theme is defined in the script under `set_git_prompt_theme_icons()`.
You can modify or extend it, then set your new theme using `export GIT_PROMPT_THEME=`.
**Q:** Does it slow down Git-heavy directories?
**A:** Negligibly. The script uses optimized Git calls and caches status checks for performance.
---
### More Information
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
---
### License
Licensed under the [MIT License](./LICENSE).
---