Skip to content

Instantly share code, notes, and snippets.

@cuneytcorbaci
Created September 24, 2024 21:54
Show Gist options
  • Save cuneytcorbaci/71d2a12a91eef54be08d9654d28e5d40 to your computer and use it in GitHub Desktop.
Save cuneytcorbaci/71d2a12a91eef54be08d9654d28e5d40 to your computer and use it in GitHub Desktop.
Add Bash PS1 Color Branch Name
# 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\]$ "
@cuneytcorbaci
Copy link
Author

screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment