# Bash Git Prompt on Ubuntu 24.04 Server [![OS](https://img.shields.io/badge/ubuntu-24.04-E95420)](#) [![Shell](https://img.shields.io/badge/shell-bash-121011)](#) [![Feature](https://img.shields.io/badge/feature-git_prompt-0078D7)](#) [![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE) Install Bash Git Prompt on Ubuntu 24.04 server. > **Note** > Safe for production use. This tool only modifies your shell prompt and does not change system services. --- ## Why this installer exists Most Bash Git prompts out there are bloated. You have to install oh-my-zsh, oh-my-bash, or some other framework that drags in far more than you need. This project is the opposite: a fast, lightweight Git status prompt based purely on Bash and Git’s own built-in commands. No frameworks, no plugins, no bloat. --- ## What this installer does ✔ Shows current Git branch and live repo status ✔ Supports **five clean themes** switchable in real time ✔ Displays staged, changed, untracked, stashed, and remote state ✔ Indicates clean/dirty status immediately ✔ Lets you customise PS1 inside/outside Git repos centrally ✔ Works seamlessly over SSH ✔ Includes an **optional** Nerd Font installer --- ## What this installer does *NOT* do It won’t stop you from running the script without reading the documentation like there’s no tomorrow. Skip the README, and whatever happens next is your headache, not a bug report. --- ### Prerequisites Requires **DejaVuSansMono Nerd Font Mono** for proper symbol display like shown below.

Extended Symbols

--- ### Prompt Structure The default prompt layout is: ```plaintext ``` Example output:

Default Theme

--- ### 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 ``` --- ## Important note about fonts (SSH users take notice) The Git prompt uses Nerd Font symbols, but: **You only need Nerd Fonts installed on your local machine.** Your terminal emulator on your laptop/workstation renders the symbols — not the server. If you SSH into the server, the prompt will display correctly **as long as your local terminal already has the Nerd Font installed**. If you are installing this on a remote server, you can safely skip the font installer. --- ## Make it happen 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

All Themes

--- ### Terminal Font Setup Set your terminal to use: ``` DejaVuSansMono Nerd Font Mono ```

Terminal Font Settings

--- ### 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). ---