-
-
Save danielalvarenga/2df8cabbd6f3041c2378 to your computer and use it in GitHub Desktop.
# Add in ~/.bashrc or ~/.bash_profile | |
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
RED="\[\033[01;31m\]" | |
YELLOW="\[\033[01;33m\]" | |
GREEN="\[\033[01;32m\]" | |
BLUE="\[\033[01;34m\]" | |
NO_COLOR="\[\033[00m\]" | |
# without host | |
PS1="$GREEN\u$NO_COLOR:$BLUE\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ " | |
# with host | |
# PS1="$GREEN\u@\h$NO_COLOR:$BLUE\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ " |
Excellent! That's work.
Need to restart Terminal
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOoo Amazing
Thanks for this snippet, but can you please tell me how to add a space before (branch)
?
Edit: NVM I figured out how to do it :)
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
# The line below is changed.
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
# without host
PS1="$GREEN\u$NO_COLOR:$BLUE\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
# with host
# PS1="$GREEN\u@\h$NO_COLOR:$BLUE\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
Excellent! Many thanks!
Excellent man!! Tranks a lot!
ooooo Amazing, Thanks a lot!
thanks man! ⭐
thanks a lot!
Awesomeee
Thanks a lot!. Worked on Pop os 22.04
🙏
Please don't ever remove this. I have it starred and I use it everytime I use a new system 😅
I tried every solution in the internet (including this) but it never worked for me. Still I can not see the branch
nice!
nice
💯
thanks! works with ubuntu 22.04
thanks, works with Ubuntu WSL
Thanks!
This is not working for me.
Thanks. Worked for me on fedora 39
Thanks!
thank you :-)
thanks
thanks
I am using Ubuntu 22.04.3 and this video was helpful: https://www.youtube.com/watch?v=RBVub5BbxdI
I did the following changes:
1.
The commented lines where the original values.
Hope this helps!
Thanks!
@psk001 this worked for me on ubuntu 22.04
Add at the end of .bashrc file:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
oh it worked. thanks a lot