Skip to content

Instantly share code, notes, and snippets.

@pmeinhardt
Created June 24, 2019 08:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmeinhardt/4863326ceadd8dd08463b60511e4a541 to your computer and use it in GitHub Desktop.
Save pmeinhardt/4863326ceadd8dd08463b60511e4a541 to your computer and use it in GitHub Desktop.
Find out what you did today
#!/usr/bin/env bash
#
# Find out what you did today
#
# Lists all your commits from repos found in the given paths.
# Use it to prepare your daily stand-up or to write job logs.
#
# Uses `git`, depends on `fd` - install via `brew install fd`.
#
# Usage:
#
# hmm [--max-depth depth] [--since duration] [path...]
#
# Examples:
#
# hmm --since '1 week ago' ~/code/project-x
# hmm | fzf --multi
# hmm | vim -
# hmm | ruby -e 'print STDIN.readlines.map(&:strip).join("; ")' | pbcopy
set -o errexit
set -o pipefail
set -o nounset
# For debugging, uncomment:
# set -o xtrace
# Configure defaults
maxdepth=3
since='1 day ago'
# Utility functions
function usage {
echo "Usage: hmm [--max-depth depth] [--since duration] [path...]" 1>&2
exit 0
}
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
--max-depth)
shift
maxdepth="$1"
;;
--since)
shift
since="$1"
;;
--help)
usage
;;
*)
break
;;
esac
shift
done
# Run
searchlog="git --git-dir={} --no-pager log --author=\"<\$(git --git-dir={} config user.email)>\" --branches='*' --since='{$since}' --pretty=tformat:'%s'"
exec fd \
--max-depth $maxdepth \
--type d \
--hidden \
--exec bash -c "$searchlog" \; \
'^\.git$' \
$*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment