Rick Cogley's Tech Logr

Short Technical Laser Bursts %%

RC Logr 20190406 181729

Saturday, 6 Apr, 2019

I often need to replace dates in the frontmatter of markdown files, in «RFC 3339» format for content in static site generator Hugo. A simple shell function using gnu date, sed, head and pbcopy puts the current timestamp on the clipboard easily. 👻

1
2
3
4
5
function date3339() {
   echo "Putting RFC3339 on Clipboard for Frontmatter"
   gdate --rfc-3339=seconds | sed 's/ /T/' | head -c -1 | pbcopy >&1
   echo "Date in RFC 3339 format on clipboard. Paste away"
}

Here is how it works:

Then just paste it where you need it. By the way, the timestamp means “18:38:19 in the timezone +9 hours ahead of GMT”, or, Japan time.

RC Logr 20190406 181729 - I often need to replace dates … Rick Cogley
Back to Home Tweet Link