Created
September 24, 2024 21:54
-
-
Save cuneytcorbaci/71d2a12a91eef54be08d9654d28e5d40 to your computer and use it in GitHub Desktop.
Add Bash PS1 Color Branch Name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In above PS1 we defined following properties | |
# \u@\h \[\033[32m\] — user, host name and its displaying color | |
# \w\[\033[33m\] — current working directory and its displaying color | |
# \$(parse_git_branch)\[\033[00m\] — git branch name and its displaying color | |
# Add the end of the ~/.bashrc file and then run "source ~/.bashrc" command. | |
# For color types "https://gist.github.com/cuneytcorbaci/9b50b0dd679bc6adfc95505fd7f8d958" | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;36m\]\$(parse_git_branch)\[\033[00m\]$ " |
Author
cuneytcorbaci
commented
Sep 24, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment