elementary / terminal

Terminal emulator designed for elementary OS
https://elementary.io
GNU Lesser General Public License v3.0
403 stars 97 forks source link

Show branch if in a git directory by default. #113

Open dkotrada opened 7 years ago

dkotrada commented 7 years ago

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
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/46572061-show-branch-if-in-a-git-directory-by-default?utm_campaign=plugin&utm_content=tracker%2F61246377&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F61246377&utm_medium=issues&utm_source=github).
struegamer commented 6 years ago

@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

MaybeThisIsRu commented 6 years ago

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

anddam commented 6 years ago

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