5.4 KiB
Git prompt for bash for Ubuntu and other distros.
This prompt is a port of magicmonty git prompt located [here] which again is a port of this one located [here]
A bash prompt with theme support that displays usefull information about the current git repository.
Prompt Structure.
The default "Out Of The Box" theme appearance of the prompt is:
(<last status> <working dir> <branch> <upstream branch>|<branch tracking> then a newline <with current time>)
And it looks like this with the default theme.
Deafult theme status symbols examples
✔
: repository clean●n
: there aren
staged files✖n
: there aren
files with merge conflicts✖-n
: there aren
staged files waiting for removal✚n
: there aren
changed but unstaged files…n
: there aren
untracked files⚑n
: there aren
stash entries↑n
: ahead of remote byn
commits↓n
: behind remote byn
commits
Installing via git clone
Remove all references for other git prompts you may have been using before installing then run.
git clone https://git.x-files.dk/bash/bash-git-prompt.git ~/.bash-git-prompt
cd ~/.bash-git-prompt
./install-fonts.sh
Then add the following to your ~/.bashrc file.
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_THEME=Default
source "$HOME/.bash-git-prompt/gitprompt.sh"
fi
Fonts
All themes except the "Default theme" wich does not use Nerd symbols have been created and tested with Ubuntu 24.04 with the following font DejaVu-Sans-Mono-Nerd-Font-Complete-Mono which is included in the repository.
To get the best experience using the supplied themes change your terminal font to use "DejaVuSansMono Nerd Font Mono"
Changing themes
In order to use another theme just change the the theme name in your ~/.bashrc file and close and repoen your terminal. Important the theme name must be entered without the .bgptheme extension. Example to change the "Default" theme with "x-files-fancy-white" all you have to do is change the following line in your ~/.bashrc file
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_THEME=Default
source "$HOME/.bash-git-prompt/gitprompt.sh"
fi
To
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_THEME=x-files-fancy-white
source "$HOME/.bash-git-prompt/gitprompt.sh"
fi
Then close and reopen your terminal.
The following themes are currently provided and can be added to your ~/.bashrc file as shown above. The themes are listed in alphabetical order.
x-files-default
x-files-chevron
x-files-fancy-white
x-files-fancy-yellow
x-files-return
x-files-return-time
x-files-robby-russell
x-files-time
Screenshot of the aditional themes currently provided with some example symbols using DejaVu-Sans-Mono-Nerd-Font font
x-files-default theme example
x-files-chevron theme example
x-files-fancy-white theme example
x-files-fancy-yellow theme example
x-files-return theme example
x-files-return-time theme example
x-files-robby-russell theme example
x-files-time theme example
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.
Search for Terminal Font Family and insert the following DejaVuSansMono Nerd Font
Search for Gpu Acceleration and set it to on
Search for Editor Font Family and insert the following 'DejaVuSansMono Nerd Font', 'monospace', monospace
More guides
More guides can be found on [wiki.x-files.dk]
Last tested
January 8th 2025 on Ubuntu 24.04.