script: ./now script for adding to nowpage
This commit is contained in:
parent
886ce662ba
commit
7fa6e6d005
1 changed files with 26 additions and 0 deletions
26
now
Executable file
26
now
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <text>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
text="$*"
|
||||
date=$(date +%d/%m/%y)
|
||||
file="$(dirname "$(readlink -f "$0")")/content/now.md"
|
||||
|
||||
awk -v date="$date" -v text="$text" '
|
||||
!inserted && /^<dl>$/ {
|
||||
print
|
||||
print ""
|
||||
print "{% update(date=\"" date "\") %}"
|
||||
print text
|
||||
print "{% end %}"
|
||||
inserted = 1
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
||||
|
||||
echo "Added entry dated $date to $file"
|
||||
Loading…
Add table
Add a link
Reference in a new issue