Skip to content

Instantly share code, notes, and snippets.

@jpwilliams
Last active March 16, 2017 09:19
Show Gist options
  • Save jpwilliams/c79f349bfb2016cbfffa3e6580ba152f to your computer and use it in GitHub Desktop.
Save jpwilliams/c79f349bfb2016cbfffa3e6580ba152f to your computer and use it in GitHub Desktop.
Log recent git commits

Installation

# For realpath, gfind and emojify
brew install coreutils findutils emojify
echo "alias glog='~/glog.sh'" >> ~/.bashrc

Usage

# check last 24 hours in current dir (recursively)
glog

# check last week in current dir (recursively)
glog 1.week

# check last 2 months in specified dir (recursively)
glog 2.months ~/my/dir

Orders oldest->newest. Checks all fetched commits as well as current, so a looping git fetch may be required before running.

Todo

Use that awesomely-fast search thing JT was using!

#! /bin/bash
DEFAULT_DIR=$PWD
LOC=${2-$DEFAULT_DIR}
function get_locs() {
gfind $(realpath $LOC) -name '.git' -not -path "*/node_modules/*" -printf '%h\n'
}
function prune() {
while read line
do
cd $line
YUP=$(git --no-pager log --all --pretty=oneline --since="$1" -n 1)
if [ ! -z "$YUP" ]
then
echo $line
fi
done
}
function log() {
while read line
do
cd $line
echo -e "\n$(basename $PWD)"
git --no-pager log --all --pretty=format:"%cd - %Cblue%h%Creset%Cgreen %s%Creset %Cred%d%Creset - %an" --since="$1" --reverse --date=format:"%a %R" | emojify
echo -e "\n"
done
}
function ggl() {
if [ -z $1 ]
then
TIME="12am"
else
TIME="$1"
fi
get_locs | prune $TIME | log $TIME
}
ggl $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment