Created
December 15, 2019 03:26
-
-
Save raybird/94052d5719d68a9ae94f24e49b1e3bb7 to your computer and use it in GitHub Desktop.
add git branch on bash-prompt
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
## INCLUDE CUSTOM `.bashrc` CODE | |
## | |
#if [ -f ~/.bashrc_custom ]; then | |
# . ~/.bashrc_custom | |
#fi | |
# THIS FILE IS A USER-CUSTOM BASHRC FILE TO KEEP CLEAN THE DEFAULT ~/.barshrc FILE. | |
# PUT THERE ANY CUSTOM CODE MANUALLY ADDED BY YOU | |
# Show git branch name | |
force_color_prompt=yes | |
color_prompt=yes | |
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 \[\033[00m\]at \[\033[01;32m\]\h \[\033[00m\]in \[\033[01;34m\]\w\[\033[00m\]\non \[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' | |
fi | |
unset color_prompt force_color_prompt |
now PS1
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\D{%F %T}\[\033[00m\] \[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[00;33m\]$(parse_git_branch)\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\n\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\D{%F %T}\[\033[00m\] \[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[00;33m\]$(parse_git_branch)\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
alias dsize='du -chd 1 | sort -h'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://xta.github.io/HalloweenBash/