September 15, 2025

Customize Bash prompt and show Git branch

In ~/.bashrc, I set PS1 to:

PS1='${debian_chroot:+($debian_chroot)}\[\033[0:36m\]\u\[\033[00m\]@\h \[\033[0:33m\]\w\[\033[00m\] $(__git_ps1 " (%s)") \n\[\033[1:35m\]\$\[\033[00m\] '

About colors

Colors are set with:

\[\033[1:36m\]\

1:36 is the code for cyan.

If a color is set for an element, it applies to the following elements. To end” the color add

\[\033[00m\] 

right after the element.

Source: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

Show Git branch in the prompt

To show Git branch’s name, follow the instructions there: https://raw.githubusercontent.com/git/git/refs/heads/master/contrib/completion/git-prompt.sh


personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki bash

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2025 by yctct is licensed under CC BY-SA 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88