-
-
Save blattmann/57bc6dfc04f1689feb240fb03525fff3 to your computer and use it in GitHub Desktop.
git in prompt
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
#======= Config to see git branch in the prompt | |
#===== get current git branch name | |
function git_branch { | |
export gitbranch=[$(git rev-parse --abbrev-ref HEAD 2>/dev/null)] | |
if [ "$?" -ne 0 ] | |
then gitbranch= | |
fi | |
if [[ "${gitbranch}" == "[]" ]] | |
then gitbranch= | |
fi | |
} | |
#===== set usercolor based on whether we are running with Admin privs | |
function user_color { | |
id | grep "Admin" > /dev/null | |
RETVAL=$? | |
if [[ $RETVAL == 0 ]]; then | |
usercolor="[0;35m"; | |
else | |
usercolor="[0;32m"; | |
fi | |
} | |
# Set prompt | |
cwdcolor='[0;34m' | |
gitcolor='[1;31m' | |
user_color | |
# Show if there are unstaged (*) and/or staged (+) changes | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
# Show if there is anything stashed ($) | |
export GIT_PS1_SHOWSTASHSTATE=1 | |
# Show if there are untracked files (%) | |
export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
# Show how we're tracking relative to upstream | |
#export GIT_PS1_SHOWUPSTREAM="verbose" | |
export GIT_PAGER='less -+$LESS -RS' | |
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash | |
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh | |
GIT_PS1_SHOWDIRTYSTATE=true | |
export PS1='\[\e${usercolor}\]\u:\[\e${cwdcolor}\]\w/\[\e${gitcolor}\]$(__git_ps1 "(%s)")\[\033[00m\]$ ' |
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
# Get git in the prompt config | |
if [ -f ~/.bash_gitprompt ]; then | |
. ~/.bash_gitprompt | |
fi | |
# ========= Aliases | |
alias tree="ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'" | |
alias removeMerged="git branch --merged | grep -v \"\*\" | xargs -n 1 git branch -d" | |
alias forceRemove="git branch --no-merged | grep -v \"\*\" | xargs -n 1 git branch -D" | |
alias apache="apachectl" | |
alias myIp="ifconfig | grep inet" | |
alias ignoreFolder="git ls-files -z | xargs -0 git update-index --assume-unchanged" | |
#alias lastdate=$(git show -s --format=%ad `git rev-list--tags --max-count=1`) | |
#alias myChangelog = "git log --pretty=format:'-(%an): %s%n%b' --since='$lastdate' | grep -v 'merge'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment