#!/bin/bash # Log output: # # * 51c333e (12 days) 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(red)%d%Creset" SUBJECT="%s" FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT" 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)/' | sed -e 's/ ago//' | # Replace (2 years, 5 months) with (2 years) #sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' | sed -e 's/(^[^<]*), [[:digit:]]+ .*months?)/)/' | # Line columns up based on } delimiter column -s '}' -t | # Page only if we need to less -FXRS } sync_to_remote() { REMOTE=$1 : ${REMOTE:="upstream"} BRANCH=`git rev-parse --abbrev-ref HEAD` echo "Synching with ${REMOTE}" git fetch ${REMOTE} && git rebase ${REMOTE}/${BRANCH}; } get_pr() { REMOTE=$2 : ${REMOTE:="upstream"} git fetch ${REMOTE} pull/${1}/head:pr/${1} git checkout pr/${1} } del_pr() { BRANCH=`git rev-parse --abbrev-ref HEAD` git checkout - && git branch -D ${BRANCH} }