diff --git a/.config/shell/functions/log b/.config/shell/functions/log index e5d990f..a952630 100644 --- a/.config/shell/functions/log +++ b/.config/shell/functions/log @@ -2,5 +2,14 @@ # edit the system log located in the docs repo, but also find the docs repo based on what ~/todo points to log() { - $EDITOR "$(git -C "$(dirname "$(realpath ~/todo)")" rev-parse --show-toplevel)/system-log" + DOCS_REPO="${DOCS_REPO:-$(git -C "$(dirname "$(realpath ~/todo)")" rev-parse --show-toplevel)}" + LOG_FILE=system-log + LOG_FILE_PATH="$DOCS_REPO/$LOG_FILE" + + if git -C "$DOCS_REPO" pull; then + $EDITOR "$LOG_FILE_PATH" + git -C "$DOCS_REPO" commit -m "$LOG_FILE" "$LOG_FILE_PATH" + else + $EDITOR "$LOG_FILE_PATH" + fi }