Skip to content

Instantly share code, notes, and snippets.

@titipata
Last active January 19, 2016 19:53
Show Gist options
  • Save titipata/a91ea46bde973d457f26 to your computer and use it in GitHub Desktop.
Save titipata/a91ea46bde973d457f26 to your computer and use it in GitHub Desktop.
Add this line to .bash_profile or .bashrc

Show Github Branch in Terminal (Mac OSX)

First do (to load git-completion.bash):

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
curl -OL http://github.com/git/git/raw/master/contrib/completion/git-completion.bash

Then change the name of git-completion to .git-completion:

mv ~/git-completion.bash ~/.git-completion.bash

Then add these lines to .bash_profile

# color constant
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BOLD=$(tput bold)
NORMAL=$(tput sgr0)

source ~/.git-prompt.sh
                                                                                
if [ -f ~/.git-completion.bash ]; then                                          
    source ~/.git-completion.bash
    export PS1='\W\[${LIME_YELLOW}\]$(__git_ps1 "(%s)")\[${NORMAL}\] > '
fi

For those who has no color tput colors give you 8, use this instead

if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
    export PS1='\W$(__git_ps1 "(%s)") > '
fi

Git Alias

This is the way that we can use some alias for Git.

git config --global alias.logg "log --graph --decorate --oneline --abbrev-commit --all"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment