Created
April 11, 2020 03:52
-
-
Save thuan1412/b2396a15a22da15d0b9cf387062f5c9e to your computer and use it in GitHub Desktop.
This file contains 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
# Add git branch if its present to PS1 | |
function parse_git_branch() { | |
output=$( git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' ) | |
if [ "$output" = "" ]; then | |
echo "" | |
else | |
echo \(git:"$output"\) | |
fi | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\]\W\[\033[1;49;32m\]$(parse_git_branch)\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\W $(parse_git_branch)\[\033[00m\]\$ ' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment