#!/usr/bin/env bash set -e # * About usage() { line80; cat </dev/null; then cat >&2 <&2 MSG=${1:-$(date +'%Y-%m-%d %H:%M:%S %Z')} if [ $# -ge 1 ]; then shift fi $GIT commit -m "$MSG" "$@" || (echo "error: commit failed" >&2; $GIT reset -q) } r() { record "$@"; } status() { ensure_git # short status $GIT --work-tree "$DIR" status -sb "$@" -- $FILES echo # diff $GIT --work-tree "$DIR" diff "$@" -- $FILES } s() { status "$@"; } log() { ensure_git # ensure_git_repo # $GIT --work-tree "$DIR" log --format='%C(yellow)%ad %Cred%h%Creset %s%C(bold blue)%d%Creset' --date=short -1000000 "$@" cd "$DIR" # TODO: limit to hledger files $GIT log --format='%ad %h %s' --date=short "$@" } l() { log "$@"; } # * Main # NOTE intended to run Commands but will run any function above if [[ "$1" == "-h" || "$1" == "--help" || $# == 0 ]]; then usage elif declare -f "$1" > /dev/null; then "$@" else ensure_git $GIT "$@" fi