From f5234cba17f7f7d2a5bc36a420694a26ddfd57c9 Mon Sep 17 00:00:00 2001 From: Ben Savage Date: Mon, 5 Jul 2021 21:47:19 +1000 Subject: [PATCH] using better git check --- cl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cl b/cl index 8fd6a10..f8eb24b 100755 --- a/cl +++ b/cl @@ -25,7 +25,11 @@ $0 - Captain's log Create a file in "$CLDIR" called "template" with the base text to add to each day - and the task will be appended to the file when it is accessed through $0 + If the file is not executable, it is treated as a static template and is copied each day. + The string {{DATE}} can be used to insert a date string. {{DATE }} can be used to replace the defualt format. + i.e {{DATE %F}} fill produce the text $(date %F). + If the file is executable, it will be run in the context of the user, and the output will be used instead. + Directories created under $BASEDIR are treated as profiles (if they exist). The default profile is assumed to be 'default'. Specify -p as the first argument to $0 to operate on a different one @@ -45,6 +49,8 @@ $0 - Captain's log ; is a general note possibly worth reviewing # is for a verbose note, probably not of general interest but was worth noting + If $CLDIR is a git repo (git rev-parse returns 0), it will be updated and auto committed unless --no-git is passed + EOF } @@ -121,7 +127,7 @@ function captains_log() { TODAY=$(date +%F) TOMORROW=$(date +%F -d "+${modT:-1} day") - if [ ${GIT:-1} ] && [ -d "$CLDIR/.git" ]; then + if [ ${GIT:-1} ] && (git -C $CLDIR rev-parse 2>/dev/null) ; then GIT=1 else GIT=0