Go to file
2025-02-03 12:59:23 +01:00
fonts initial commit 2025-02-03 12:59:23 +01:00
themes initial commit 2025-02-03 12:59:23 +01:00
gitprompt.sh initial commit 2025-02-03 12:59:23 +01:00
gitstatus.sh initial commit 2025-02-03 12:59:23 +01:00
gpchange.sh initial commit 2025-02-03 12:59:23 +01:00
gpthemes.sh initial commit 2025-02-03 12:59:23 +01:00
install-fonts.sh initial commit 2025-02-03 12:59:23 +01:00
prompt-colors.sh initial commit 2025-02-03 12:59:23 +01:00
README.md initial commit 2025-02-03 12:59:23 +01:00

Bash git prompt for Ubuntu desktop 22.04 and 24.04

This is a bash git prompt with theme support that displays usefull information about the current git repository.

This prompt is a fork of magicmonty git prompt located [here] which again is a port of this one located [here] I suspect none of the ports are maintained anlylonger and this is why I decided to fork it. Besides a few changes to the original port new themes has been created and some themes has been removed.

Prompt Structure.

The default "Out Of The Box" theme appearance of the prompt looks like this. I removed the time stamp from the default theme btw.

<last status><working dir><branch><upstream branch>|<branch tracking>

And it looks like this with the default theme.

default theme

Theme symbols used with the default theme.

default symbols

Theme symbols used with the additional themes provided requires DejaVuSansMono Nerd Font Mono to be present.

extended symbols

Install via git clone

git clone https://git.x-files.dk/ubuntu-desktop/bash-git-prompt.git ~/.bash-git-prompt

Install the required fonts needed for all other themes exept the deafault theme.

cd ~/.bash-git-prompt
./install-fonts.sh

Next set your terminal to use the DejaVuSansMono Nerd Font Mono as shown below.

Terminal font settings

Getting everything up and running.

Important: Remove all references for other git prompts you may have running. Then add the following to your ~/.bashrc file.

if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
    GIT_PROMPT_THEME=default
    alias gpchange="bash $HOME/.bash-git-prompt/gpchange.sh"
    alias gpthemes="bash $HOME/.bash-git-prompt/gpthemes.sh"
    source "$HOME/.bash-git-prompt/gitprompt.sh"
fi

Changing themes method 1

Edit your ~/.bashrc file and change the line GIT_PROMPT_THEME=theme with another theme. For example to change the default theme to something else change.

if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
    GIT_PROMPT_THEME=default
    alias gpchange="bash $HOME/.bash-git-prompt/gpchange.sh"
    alias gpthemes="bash $HOME/.bash-git-prompt/gpthemes.sh"
    source "$HOME/.bash-git-prompt/gitprompt.sh"
fi

To

if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
    GIT_PROMPT_THEME=fancy-white
    alias gpchange="bash $HOME/.bash-git-prompt/gpchange.sh"
    alias gpthemes="bash $HOME/.bash-git-prompt/gpthemes.sh"
    source "$HOME/.bash-git-prompt/gitprompt.sh"
fi

Then close and reopen your terminal.

Changing themes method 2

In your terminal type gpchange and type name of the theme you would like to use. Then close and reopen your terminal. The following themes are currently provided and can be added to your ~/.bashrc file as shown above or using the gpchange command.

default
fancy-orange
fancy-white
fancy-gold
half-life
hazard
robby-russell
this-way
two-liner
two-liner-time
x-files
x-files-time

Display all themes in the terminal.

You can run the command gpthemes in your terminal in order to get a showcase of all available themes.

Screenshot of the additional themes currently provided.

x-files theme
Theme name: x-files

x-files-time theme
Theme name: x-files-time

robby-russel theme
Theme name: robby-russel

this-way theme
Theme name: this way

two-liner theme
Theme name: two-liner

two-liner-time theme
Theme name: two-liner-time

fancy-white theme
Theme name: fancy-white

fancy-gold theme
Theme name: fancy-gold

fancy-orange theme
Theme name: fancy-orange

half-life theme
Theme name: half-life

hazard theme
Theme name: hazard

Note on VS Code

In order to get this to work in the VS Code terminal you will have to adjust a few settings for the symbols to render correctly. Open "File -> Preferences -> Settings" then adjust the following.

vscode settings
Search for Terminal Font Family and insert the following DejaVuSansMono Nerd Font

vscode settings
Search for Gpu Acceleration and set it to on

vscode settings
Search for Editor Font Family and insert the following 'DejaVuSansMono Nerd Font', 'monospace', monospace

More guides can be found on [wiki.x-files.dk]

Last tested

January 8th 2025 on Ubuntu 24.04.