-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatedooter.sh
More file actions
executable file
·40 lines (31 loc) · 1018 Bytes
/
datedooter.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# datedooter.sh - Update words post timestamp to current time
# Usage: ./datedooter.sh <post-name>
# Example: ./datedooter.sh email-is-hard
set -e
if [ $# -eq 0 ]; then
echo "Usage: $0 <post-name>"
echo "Example: $0 email-is-hard"
exit 1
fi
POST_NAME="$1"
POST_FILE="content/words/${POST_NAME}.md"
# Check if file exists
if [ ! -f "$POST_FILE" ]; then
echo "Error: File '$POST_FILE' not found"
exit 1
fi
# Generate current timestamp in ISO 8601 format with timezone
# Format: 2025-11-11T19:18:11-08:00
TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/')
echo "Updating timestamp in $POST_FILE"
echo "New timestamp: $TIMESTAMP"
# Update the date field in the frontmatter (macOS sed requires -i '' for in-place editing)
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s/^date = \".*\"$/date = \"$TIMESTAMP\"/" "$POST_FILE"
else
# Linux
sed -i "s/^date = \".*\"$/date = \"$TIMESTAMP\"/" "$POST_FILE"
fi
echo "Done."