Powerline for Git Bash, done in C#.
Powerline is great, but I wanted more customizations and also want to use it on Windows.
I ran into 2 powerline repositories by sschleemilch. One is done in C# and another one is done in C++.
Diving inside the repositories, I soon learnt how easy it was to create a program to do all the Powerline stuff for you.
So I went ahead to make my own variant.
For the glyphs to render properly, you need a font that can do all that. nerd-fonts is what I use for this.
I used specific glyphs from specific sets for certain symbols. If you are patching a font using Nerd Font's font-patcher and don't want to add every glyph set into your font, I've narrowed down on what glyph sets I used (the command-line options are what should be used in font-patcher to get the font with just the glyph sets that I used in this program):
- Powerline Symbols (
--powerline
) - Octicons (
--octicons
) - Font Awesome Extension (
--fontawesomeext
) - Markdown (
--markdown
)
-
Head over to the Releases page and download GitBashPowerlineNET.zip from the version you want.
-
Unzip the zipped file. You should receive 2 files: git2-a2bde63.dll and GitBashPowerlineNET.exe. These 2 files must be placed beside each other, else the program will fail.
-
Move the files to somewhere convenient.
-
Open up your
.bashrc
file and append the following to it. Make sure to changepath-to-exe
to the path to where you moved the executable:function _set_ps1_to_powerline() { local last_command_exit_code=$? local path_to_exe="change-me-to-the-path-to-the-exe" # if the executable doesn't exist, then don't change PS1 if [[ -e $path_to_exe ]]; then PS1_CONTENT="$("$path_to_exe" $last_command_exit_code)" PS1="\n$(echo -e $PS1_CONTENT) " fi } PROMPT_COMMAND="_set_ps1_to_powerline; $PROMPT_COMMAND"
-
Re-launch Git Bash. You may also run
source your-bash-rc
instead, but take note thatPROMPT_COMMAND
will become longer, resulting in more commands to execute and thus, may cause slowdowns. -
Your Git Bash should now start showing powerline segments like this (some segments might not show up depending on your current directory):
If so, congratulations!
By default, your username, current directory and prompt will be shown.
The Git segment is placed on the left after the current directory and displays some information about the Git repository you're in.
By default, it shows the name of the branch you're currently checked out.
If you are currently checked out on a commit, the Git segment will update and show you the commit ID instead of the branch name.
If you're in a middle of a merge, the segment will display an icon to the right.
If you're in the middle of a cherry pick, the segment will display an icon to the right.
If you're in the middle of a rebase, the segment will display an icon to the right.
If you're in the middle of a revert, the segment will display an icon to the right.
If you're in the middle of bisecting, the segment will display an icon to the right.
If a non-zero error code is produced by the last command, then it will be shown the next time the prompt is displayed.