Nathan SoboWIPbcd0e8b1 year agoHistory
25 lines · 844 B · Shell
RawDownload
#!/usr/bin/env bashset -euo pipefail # Collect metadataDATETIME_TZ=$(date '+%Y-%m-%d %H:%M:%S %Z')FILENAME_TS=$(date '+%Y-%m-%d_%H-%M-%S') if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then  REPO_ROOT=$(git rev-parse --show-toplevel)  REPO_NAME=$(basename "$REPO_ROOT")  GIT_BRANCH=$(git branch --show-current 2>/dev/null || git rev-parse --abbrev-ref HEAD)  GIT_COMMIT=$(git rev-parse HEAD)else  REPO_ROOT=""  REPO_NAME=""  GIT_BRANCH=""  GIT_COMMIT=""fi # Print similar to the individual command outputsecho "Current Date/Time (TZ): $DATETIME_TZ"[ -n "$GIT_COMMIT" ] && echo "Current Git Commit Hash: $GIT_COMMIT"[ -n "$GIT_BRANCH" ] && echo "Current Branch Name: $GIT_BRANCH"[ -n "$REPO_NAME" ] && echo "Repository Name: $REPO_NAME"echo "Timestamp For Filename: $FILENAME_TS"