Skip to content

Instantly share code, notes, and snippets.

@ferminhg
Created July 31, 2020 17:21
Show Gist options
  • Save ferminhg/c2229a3038eca79c3746d2ac0ece7145 to your computer and use it in GitHub Desktop.
Save ferminhg/c2229a3038eca79c3746d2ac0ece7145 to your computer and use it in GitHub Desktop.
Shell script to create a daily file `20200731.md`
#!/bin/bash
# ./create_daily.sh [--tomorrow]
# Flags: (--tomorrow) to create the file for tomorrow
if [ "$1" == "--tomorrow" ] ; then
# not need to be initializaded
DATE_PARAM="-v +1d"
fi
DAILY_PATH=$(dirname "$0")
DATE_FILE=$(date $DATE_PARAM '+%Y%m%d')
DAILY_FILE=$DAILY_PATH/$DATE_FILE.md
if [ -f "$DAILY_FILE" ]; then
exit
fi
DATE_TITLE=$(date $DATE_PARAM '+%Y-%m-%d')
cat > $DAILY_FILE << EOF
# $DATE_TITLE
## TODO
- [ ] task1
- [ ] task2
- [ ] task3
## Notes
## Links
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment