Computersnyou

Setting up colors in terminal with Git $PS1 to display current branch and git bash completion

Posted on  9/11/2012
If you are active developer and use git very much for your projects then you might want to use terminal to show and track current brach of git you can do it with simples steps

git bash completion mac and git brach listing in terminal 
Demonstrated under mac terminal and login shell enabled 

this will also install  git bash completion
git bash completion mac will work with only if you installed git via official package if you installed through brew in mac then

open your .bash_login or .bashrc file and paste

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PATH="$HOME/bin:$PATH"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
source /usr/local/git/contrib/completion/git-completion.bash
PS1='[u@h w$(__git_ps1 " (%s)")]$ '
<tr>
  <td class="tr-caption" style="text-align: center;">
    terminal with colors
  </td>
</tr>

if you installed git via brew then replace

source /usr/local/git/contrib/completion/git-completion.bash

with this to enable git bash completion

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi
<tr>
  <td class="tr-caption" style="text-align: center;">
    Git Current Branch with git bash Completion
  </td>
</tr>

  • Home
  • About