netj / dotfiles

netj's dotfiles
Other
54 stars 10 forks source link

how to incorporate git branch into bash terminal #1

Open bongsoos opened 9 years ago

bongsoos commented 9 years ago

I want to have git branch information but if I write the below code to the bash_local, I lose the original setting. How do I keep the original setting and incorporate the following code? The below code is from "software carpentry".

Set the prompt to show the current git branch:

function parse_git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" }

PS1="\h:\W$RED \$(parse_git_branch)$NO_COLOR $"

netj commented 9 years ago

The bash prompt is handled by the prompt plugin in bpm. There's no easy way to extend it yet. But we can certainly brainstorm how to do that, perhaps by splitting the current monolithic plugin into multiple pieces that incrementally displays hostname, pwd, date/time, and adding a new piece that displays git branch in a nice way.