bash-git-prompt/README.md
2025-01-09 10:54:35 +01:00

137 lines
5.4 KiB
Markdown

## Git prompt for bash for Ubuntu and other distros.
This prompt is a port of magicmonty git prompt located [\[here\]](https://github.com/magicmonty/bash-git-prompt) which again is a port of this one located [\[here\]](https://github.com/olivierverdier/zsh-git-prompt)
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:
```plaintext
(<last status> <working dir> <branch> <upstream branch>|<branch tracking> then a newline <with current time>)
```
### And it looks like this with the default theme.
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-prompt-default.png" alt="default layout"/>
</p>
### Deafult theme status symbols examples
- ``✔``: repository clean
- ``●n``: there are ``n`` staged files
- ``✖n``: there are ``n`` files with merge conflicts
- ``✖-n``: there are ``n`` staged files waiting for removal
- ``✚n``: there are ``n`` changed but *unstaged* files
- ``…n``: there are ``n`` untracked files
- ``⚑n``: there are ``n`` stash entries
- ``↑n``: ahead of remote by ``n`` commits
- ``↓n``: behind remote by ``n`` 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
```
```bash
cd ~/.bash-git-prompt
./install-fonts.sh
```
Then add the following to your ~/.bashrc file.
```bash
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
```bash
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_THEME=Default
source "$HOME/.bash-git-prompt/gitprompt.sh"
fi
```
To
```bash
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
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-default.png" alt="x-files-default theme"/><br>x-files-default theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-chevron.png" alt="x-files-chevron theme"/><br>x-files-chevron theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-fancy-white.png" alt="x-files-fancy-white theme"/><br>x-files-fancy-white theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-fancy-yellow.png" alt="x-files-fancy-yellow theme"/><br>x-files-fancy-yellow theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-return.png" alt="x-files-return theme"/><br>x-files-return theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-return-time.png" alt="x-files-return-time theme"/><br>x-files-return-time theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-robby-russell.png" alt="x-files-robby-russell theme"/><br>x-files-robby-russell theme example
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-time.png" alt="x-files-time theme"/><br>x-files-time theme example
</p>
### 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.
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-vscode1.png" alt="vscode settings"/><br>Search for <b><i>Terminal Font Family</i></b> and insert the following <b><i>DejaVuSansMono Nerd Font</i></b>
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-vscode2.png" alt="vscode settings"/><br>Search for <b><i>Gpu Acceleration</i></b> and set it to <b><i>on</i></b>
</p>
<p align="left" width="100%">
<img src="https://git.x-files.dk/assets/bash-git-vscode3.png" alt="vscode settings"/><br>Search for <b><i>Editor Font Family</i></b> and insert the following <b><i>'DejaVuSansMono Nerd Font', 'monospace', monospace</i></b>
</p>
### More guides
More guides can be found on [\[wiki.x-files.dk\]](https://wiki.x-files.dk)
### Last tested
January 8th 2025 on Ubuntu 24.04.