terminal
terminal copied to clipboard
Show branch if in a git directory by default.
Please consider to add this to .bashrc by default.
# Add git branch if its present to PS1
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@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
@dkotrada A much better wish would be to distrbute something like https://github.com/arialdomartini/oh-my-git (Oh My Git Prompt) which works for bash and zsh i.e. It has more information on the prompt lines and can be themed
@sadig Seems like an overkill for an otherwise simplistic and friendly distribution. ggpnp or ggl is not friendly for anyone - except those who them often (and will most likely be experienced enough to install them anyway). For most, I reckon simply showing the git branch by default works well and pleases them.
Does this even belong to terminal, considering it's a setting specific to git used in bash?