Created
April 15, 2013 21:12
-
-
Save paulfryzel/5391327 to your computer and use it in GitHub Desktop.
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
# from: https://github.com/hashrocket/dotmatrix/blob/master/.hashrc | |
alias ll='ls -l' | |
# git_prompt_info accepts 0 or 1 arguments (i.e., format string) | |
# returns text to add to bash PS1 prompt (includes branch name) | |
git_prompt_info () { | |
local g="$(git rev-parse --git-dir 2>/dev/null)" | |
if [ -n "$g" ]; then | |
local r | |
local b | |
local d | |
local s | |
# Rebasing | |
if [ -d "$g/rebase-apply" ] ; then | |
if test -f "$g/rebase-apply/rebasing" ; then | |
r="|REBASE" | |
fi | |
b="$(git symbolic-ref HEAD 2>/dev/null)" | |
# Interactive rebase | |
elif [ -f "$g/rebase-merge/interactive" ] ; then | |
r="|REBASE-i" | |
b="$(cat "$g/rebase-merge/head-name")" | |
# Merging | |
elif [ -f "$g/MERGE_HEAD" ] ; then | |
r="|MERGING" | |
b="$(git symbolic-ref HEAD 2>/dev/null)" | |
else | |
if [ -f "$g/BISECT_LOG" ] ; then | |
r="|BISECTING" | |
fi | |
if ! b="$(git symbolic-ref HEAD 2>/dev/null)" ; then | |
if ! b="$(git describe --exact-match HEAD 2>/dev/null)" ; then | |
b="$(cut -c1-7 "$g/HEAD")..." | |
fi | |
fi | |
fi | |
# Dirty Branch | |
local newfile='?? ' | |
if [ -n "$ZSH_VERSION" ]; then | |
newfile='\?\? ' | |
fi | |
d='' | |
s=$(git status --porcelain 2> /dev/null) | |
[[ $s =~ "$newfile" ]] && d+='+' | |
[[ $s =~ "M " ]] && d+='*' | |
[[ $s =~ "D " ]] && d+='-' | |
printf "${1-"(%s) "}" "${b##refs/heads/}$r$d" | |
fi | |
} | |
gco () { | |
if [[ $1 == '.' ]]; then | |
git add -A | |
git commit -m "CHECKING OUT CURRENT DIRECTORY" -q | |
git reset HEAD^ -q | |
git checkout . | |
else | |
git checkout "$@" | |
fi | |
} | |
alias gap='git add -p' | |
alias gnap='git add -N . && git add -p' | |
alias gb='git branch' | |
alias gc='git commit -v' | |
alias gca='git commit -a -v' | |
alias gd='git diff' | |
alias gdc='git diff --cached' | |
alias gdh='git diff HEAD' | |
alias gl='git pull' | |
alias glod='git log --oneline --decorate' | |
alias gln="git ln | perl -ple 's/\*/sprintf(\"%2s\", \$n++)/e' | less" | |
alias gp='git push' | |
alias gpr='git pull --rebase' | |
alias gst='git status' | |
alias gr='git rebase' | |
alias grc='git rebase --continue' | |
alias gra='git rebase --abort' | |
alias reset-authors='git commit --amend --reset-author -C HEAD' | |
alias vi='vim' | |
[ -z "$PS1" ] || stty -ixon | |
[ -z "$PS1" ] || export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$(git_prompt_info '(%s)')$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment