Skip to content

Instantly share code, notes, and snippets.

@garyharan
Created March 24, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garyharan/ca3da8000b755a7fda29 to your computer and use it in GitHub Desktop.
Save garyharan/ca3da8000b755a7fda29 to your computer and use it in GitHub Desktop.
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
required = true
[color]
ui = auto
[user]
name = Gary Haran
email = gary.haran@gmail.com
[mergetool "Kaleidoscope"]
cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot
trustexitcode = true
[merge]
tool = Kaleidoscope
[difftool "Kaleidoscope"]
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
[mergetool]
prompt = false
[diff]
tool = Kaleidoscope
[push]
default = current
[alias]
alias = config --get-regexp ^alias\\.
co = checkout
# http://haacked.com/archive/2014/07/28/github-flow-aliases/
ec = config --global -e
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
cob = checkout -b
cm = !git add -A && git commit -m
amend = commit -a --amend
# like a reset but better. Use reflog to find savepoint
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# from https://github.com/garybernhardt/dotfiles/blob/master/.gitconfig
h = !git head
hp = "!. ~/.githelpers && show_git_head"
r = !GIT_NO_PAGER=1 git l -30
ra = !git r --all
l = "!. ~/.githelpers && pretty_git_log"
la = !git l --all
#!/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|remote-tracking branch|pull request) .*$)/$(printf $ANSI_RED)\1$(printf $ANSI_RESET)/" |
# Page only if we're asked to.
if [ -n "$GIT_NO_PAGER" ]; then
cat
else
# Page only if needed.
less --quit-if-one-screen --no-init --RAW-CONTROL-CHARS --chop-long-lines
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment