Skip to content

Commit

Permalink
Aliases and stuff from DAS
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanp committed Dec 4, 2013
1 parent 481fe87 commit 0e2b66d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 9 deletions.
41 changes: 32 additions & 9 deletions .gitconfig
Expand Up @@ -4,19 +4,42 @@
[apply]
whitespace = nowarn
[color]
diff = auto
status = auto
branch = auto
ui = auto
[alias]
st = status
ci = commit
co = checkout
br = branch
di = diff
dc = diff --cached
amend = commit --amend
aa = add --all
ff = merge --ff-only
pullff = pull --ff-only
noff = merge --no-ff
fa = fetch --all
pom = push origin master
b = branch
ds = diff --stat=160,120
dh1 = diff HEAD~1

# Fancy logging.
# h = head
# hp = head with patch
# r = recent commits, only current branch
# ra = recent commits, all reachable refs
# l = all commits, only current branch
# la = all commits, all reachable refs
head = !git l -1
h = !git head
hp = "!. ~/.githelpers && show_git_head"
r = !git l -30
ra = !git r --all
l = "!. ~/.githelpers && pretty_git_log"
la = !git l --all
[core]
excludesfile = /Users/bryanp/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[diff]
tool = vimdiff
[branch]
autosetuprebase = always
61 changes: 61 additions & 0 deletions .githelpers
@@ -0,0 +1,61 @@
#!/bin/bash

# Log output:
#
# * 51c333e (12 days) <Gary Bernhardt> add vim-eunuch
#
# The time massaging regexes start with ^[^<]* because that ensures that they
# only operate before the first "<". That "<" will be the beginning of the
# author name, ensuring that we don't destroy anything in the commit message
# that looks like time.
#
# The log format uses } characters between each field, and `column` is later
# used to split on them. A } in the commit subject or any other field will
# break this.

HASH="%C(yellow)%h%Creset"
RELATIVE_TIME="%Cgreen(%ar)%Creset"
AUTHOR="%C(bold blue)<%an>%Creset"
REFS="%C(bold red)%d%Creset"
SUBJECT="%s"

FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"

ANSI_BLACK='\033[30m'
ANSI_BLACK_BOLD='\033[0;30;1m'
ANSI_RED='\033[31m'
ANSI_RED_BOLD='\033[0;31;1m'
ANSI_GREEN='\033[32m'
ANSI_GREEN_BOLD='\033[0;32;1m'
ANSI_YELLOW='\033[33m'
ANSI_YELLOW_BOLD='\033[0;33;1m'
ANSI_BLUE='\033[34m'
ANSI_BLUE_BOLD='\033[0;34;1m'
ANSI_MAGENTA='\033[35m'
ANSI_MAGENTA_BOLD='\033[0;35;1m'
ANSI_CYAN='\033[36m'
ANSI_CYAN_BOLD='\033[0;36;1m'
ANSI_WHITE='\033[37m'
ANSI_WHITE_BOLD='\033[0;37;1m'
ANSI_RESET='\033[0m'


show_git_head() {
pretty_git_log -1
git show -p --pretty="tformat:"
}

pretty_git_log() {
git log --graph --pretty="tformat:${FORMAT}" $* |
# Replace (2 years ago) with (2 years)
sed -Ee 's/(^[^<]*) ago\)/\1)/' |
# Replace (2 years, 5 months) with (2 years)
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?\)/\1)/' |
# Line columns up based on } delimiter
column -s '}' -t |
# Color merge commits specially
sed -Ee "s/(Merge branch .* into .*$)/$(printf $ANSI_RED)\1$(printf $ANSI_RESET)/" |
# Page only if we need to
less -FXRS
}

0 comments on commit 0e2b66d

Please sign in to comment.