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