Friday, September 10, 2010

Git Completion, Git Branch in Shell Prompt


  1. which git --> /usr/local/git/bin/git, so /usr/local/git is {GIT_HOME}

  2. cp {GIT_HOME}/contrib/completion/git-completion.bash ~/.git-completion.sh

  3. vi ~/.profile (or .bashrc if on Linux)

  4. insert into end of .profile:

    source ~/.git-completion.sh
    PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

Open a new terminal window and enjoy.