Created
May 30, 2014 01:08
-
-
Save Chun-Yang/8b26944df7d52649020a to your computer and use it in GitHub Desktop.
git short cut, show git status and branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias subl="sublime" | |
| # git alias | |
| alias gs='git status' | |
| alias ga='git add -A' | |
| alias gb='git branch' | |
| alias gc='git commit -m ' | |
| alias gl='git log' | |
| alias gp='git push' | |
| alias go='git checkout ' | |
| alias gd='git diff' | |
| alias gdab='git diff' | |
| alias gdbc='git diff --cached' | |
| alias gdcd='git diff HEAD' | |
| alias gba='git branch --all' | |
| # show git dirty status | |
| function parse_git_dirty { | |
| [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*" | |
| } | |
| function parse_git_branch { | |
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
| } | |
| # export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ ' | |
| # with color | |
| export PS1='\[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ ' | |
| # without color | |
| # export PS1='\w$(parse_git_branch)$ ' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment