#!/usr/bin/env bash NOTEBOOK_DIR=~/notebook if [[ ! -d "$NOTEBOOK_DIR" ]]; then echo "Error: Notebook directory does not exist at $NOTEBOOK_DIR" exit 1 fi cd "$NOTEBOOK_DIR" || exit 1 show_help() { cat << EOF nb - Notebook management tool Usage: nb Commands: save Commit changes with timestamp sync Save, fetch, and push changes log Show commit log diff Show differences status Show diff summary EOF } case "$1" in save) jj diff -r @ --summary | grep -q . && jj commit -m "$(date +"%Y-%m-%dT%H:%M:%S%z")" && jj tug || true ;; sync) "$0" save && jj git fetch && jj git push ;; log) jj log -r ".." ;; diff) jj diff ;; status) jj diff -s ;; "") show_help ;; *) echo "Error: Unknown command '$1'" echo "" show_help exit 1 ;; esac