Skip to content

Instantly share code, notes, and snippets.

@vergenzt
Created June 19, 2012 16:00
Show Gist options
  • Save vergenzt/2954971 to your computer and use it in GitHub Desktop.
Save vergenzt/2954971 to your computer and use it in GitHub Desktop.
git ps1 with modification marker
alias ls='ls -F'
#alias grep='grep --color=auto'
# Git completion stuff
# Credit to bronson on Github
# https://raw.github.com/bronson/dotfiles/731bfd951be68f395247982ba1fb745fbed2455c/.bashrc
__define_git_completion () {
eval "
_git_$2_shortcut () {
COMP_LINE=\"git $2\${COMP_LINE#$1}\"
let COMP_POINT+=$((4+${#2}-${#1}))
COMP_WORDS=(git $2 \"\${COMP_WORDS[@]:1}\")
let COMP_CWORD+=1
local cur words cword prev
_get_comp_words_by_ref -n =: cur words cword prev
_git_$2
}
"
}
__git_shortcut () {
type _git_$2_shortcut &>/dev/null || __define_git_completion $1 $2
alias $1="git $2 $3"
complete -o default -o nospace -F _git_$2_shortcut $1
}
__git_shortcut ga add
__git_shortcut gap add -p
__git_shortcut gb branch
__git_shortcut gba branch -a
__git_shortcut gco checkout
__git_shortcut go commit -v
__git_shortcut gd diff
__git_shortcut gdc diff --cached
__git_shortcut gds diff --stat
__git_shortcut gf fetch
__git_shortcut gl log
__git_shortcut glp log -p
__git_shortcut gls log --stat
alias gs='git status' # no completion for git status
#export PS1="\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w$(__git_ps1)\033[0m\] $"
# Regular Colors
Black="\[\033[0;30m\]" # Black
Red="\[\033[0;31m\]" # Red
BRed="\[\033[1;31m\]" # Bold red
Green="\[\033[0;32m\]" # Green
BGreen="\[\033[1;32m\]" # Bold green
Yellow="\[\033[0;33m\]" # Yellow
BYellow="\[\033[1;33m\]" # Bold yellow
Cyan="\[\033[0;36m\]" # Cyan
Gray="\[\033[1;30m\]" # Gray
White="\[\033[0;37m\]" # White
export PS1="\
\[\033]0;$MSYSTEM:\w\007\
$Gray[\t] \
$Green\u@\h \
$Yellow\W \
\$(\
# get the reference description
if refname=\$(git name-rev --name-only HEAD 2> /dev/null); then\
# on a branch
if curbranch=\$(git symbolic-ref HEAD 2> /dev/null); then\
echo -n '$Cyan('\${curbranch##refs/heads/}')';\
# detached head
else\
# unreachable
if [ \$refname = 'undefined' ]; then\
echo -n '$BRed(Unreachable detached HEAD: '\$(git rev-parse HEAD | head -c7)')';\
# reachable
else\
echo -n '$White('\$(git rev-parse HEAD | head -c7)': '\$refname')';\
fi;\
fi;\
git diff --quiet --cached &> /dev/null \
|| echo -n '$BGreen*';\
git diff --quiet &> /dev/null \
|| echo -n '$BRed*';\
git status --porcelain 2> /dev/null | grep -q ^?? \
&& echo -n '$Gray*';\
fi\
)\
\n$White$ "
notes() {
pushd ~/notes > /dev/null;
vim notes.txt;
go -am "update notes.txt" && git push;
pushd > /dev/null;
}
PATH="$PATH:/c/Users/tvergenz.ALIGN/Downloads/TrueCrypt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment