Skip to content

Instantly share code, notes, and snippets.

@whilp
Created March 29, 2012 22:30
Show Gist options
  • Select an option

  • Save whilp/2244407 to your computer and use it in GitHub Desktop.

Select an option

Save whilp/2244407 to your computer and use it in GitHub Desktop.
gitconfig
[alias]
st = status -s
ci = commit
ca = commit -a
glog = log --oneline --decorate --graph
tags = tag -l
man = ls-files
bare = config --bool core.bare true
[mergetool]
prompt = false
[merge]
tool = vimdiff
conflictstyle = diff3
[format]
pretty = format:"%h:%p %d %ai %ce%n %s%n"
[core]
editor = giteditor
[url "[email protected]:"]
insteadOf = gh:
#!/bin/sh
abspath () {
cd -P -- "$(dirname -- "$1")" && echo "$(pwd -P)/$(basename -- "$1")"
}
_vi () {
${EDITOR} "$1"
return $?
}
_vim () {
${EDITOR} \
"+startinsert" \
"+e diff" \
"+set buftype=help filetype=diff" \
"+split $1" \
"+resize 5" || return $?
[ -s $1 ] || return 1
return $?
}
pwd="$PWD"
msg="$(abspath $1)"
tmp=$(umask 077 && \
mktemp -dt .vcseditor 2>/dev/null || \
mktemp -td .vcseditor-XXXXXXXX)
trap "rm -rf $tmp" 0 1 2 3 6 15
_hgeditor () {
sed -Ee '1,/^HG: --/d' < "$msg" >> msg
sed -nEe "s/^HG: changed //p" < "$msg" > paths
(cd "$pwd"; xargs hg diff --stat) < paths > stat
(cd "$pwd"; xargs hg diff) < paths > diffs
(cat stat; echo; cat diffs) > diff
}
_giteditor () {
sed -Ee '1,3d; 5,7d; $d' < "$msg" >> msg
sed -nEe "s/^.*modified: *//p" < "$msg" > paths
(cd "$pwd"; xargs git diff --cached --stat) < paths > stat
(cd "$pwd"; xargs git diff --cached) < paths > diffs
(cat stat; echo; cat diffs) > diff
}
(
cd "$tmp"
echo "" > msg
echo "" > diff
case "$0" in
*hgeditor) _hgeditor $*;;
*giteditor) _giteditor $*;;
esac
fn=_$(basename ${EDITOR})
$fn msg
mv msg "$msg"
)
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment