Read the front matter to get the title for TILs
- ID
1320870- date
2024-01-26 16:06:06+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
7e8c385- message
Read the front matter to get the title for TILs- changed files
1 file, 2 additions, 7 deletions
Changed files
textexpander/create_til_commit_message (568) → textexpander/create_til_commit_message (441)
diff --git a/textexpander/create_til_commit_message b/textexpander/create_til_commit_message
index 531489c..fdeac19 100755
--- a/textexpander/create_til_commit_message
+++ b/textexpander/create_til_commit_message
@@ -5,14 +5,9 @@ set -o errexit
set -o nounset
pushd ~/repos/til >/dev/null
- markdown_file=$(git diff --cached --name-only | grep -v README.md | head -n 1)
- title=$(basename "$markdown_file")
+ markdown_file=$(git diff --cached --name-only | head -n 1)
- # Strip trailing double quotes from the end
- title="${title%\"}"
-
- # Strip the .md file extension
- title="${title%.md}"
+ title=$(grep 'title:' "$markdown_file" | sed 's/^title: //')
# Use printf rather than echo so it prints Unicode escapes,
# e.g. "that\342\200\231s" ~> "that’s"