Note:Show git branch in bash prompt


Reference:

How to show current git branch with colors in Bash prompt

https://thucnc.medium.com/how-to-show-current-git-branch-with-colors-in-bash-prompt-380d05a24745


vim ~/.bashrc

parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

if [ "$color_prompt" = yes ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1="\[\033[01;32m\]\u@\h\[\033[00m\]: \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
else


mirochiu@mirochiu-d820mt: /mnt/hdd2/node.repo/linebot_speech (master)$ c    



留言