terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Show branch if in a git directory by default.

Open dkotrada opened this issue 8 years ago • 3 comments
trafficstars

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 avatar Jun 25 '17 14:06 dkotrada

@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

struegamer avatar Dec 08 '17 12:12 struegamer

@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.

MaybeThisIsRu avatar Dec 09 '17 10:12 MaybeThisIsRu

Does this even belong to terminal, considering it's a setting specific to git used in bash?

anddam avatar Feb 08 '18 15:02 anddam