Terminal improvements for git
1 min read
Improvement #1: adding the current branch name after the current path. Add this in your .bash_profile file:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1='\[\e[0;32m\]\u\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\[\e[0;35m\]$(parse_git_branch)\[\e[0m\]$ 'And the outcome is user:path (branch_name) $ . The user is green, the path is yellow, the branch_name is purple and everything else is white.
Improvement #2: autocompletion for branch names. Again, add this in your .bash_profile file:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fiI find these pretty useful. Actually, I find them indispensable after a prolonged use. Don't forget to tweak the colors to your own preferences.