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
This is the way that we can use some alias
for Git.
git config --global alias.logg "log --graph --decorate --oneline --abbrev-commit --all"