Last active
July 22, 2020 02:15
-
-
Save pmbauer/9285d6a6c72fc86d9300f28042642ca6 to your computer and use it in GitHub Desktop.
roam weekly plan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
roam_date() { | |
date -d "${*}" '+%B %eXX, %Y' \ | |
| sed -e 's/11XX/11th/; s/12XX/12th/; s/13XX/13th/' \ | |
-e 's/1XX/1st/; s/2XX/2nd/; s/3XX/3rd/' \ | |
-e 's/XX/th/; s/ / /' | |
} | |
ONE_DAY=$((60 * 60 * 24)) | |
week_start=$(date -d "${*:-next Monday}" "+%s") | |
cat <<END | |
Week:: [[$(roam_date @$((${week_start} + ${ONE_DAY} * 0)))]] | |
## Top Weekly Goals | |
## [[Weekly Habits]] | |
- | |
## Daily Goals | |
- Monday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 0)))]] | |
- Tuesday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 1)))]] | |
- Wednesday: [[$(roam_date @$((${week_start} + ${ONE_DAY} * 2)))]] | |
- Thursday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 3)))]] | |
- Friday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 4)))]] | |
- Saturday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 5)))]] | |
- Sunday: [[$( roam_date @$((${week_start} + ${ONE_DAY} * 6)))]] | |
END |
Script needs a GNU userland, so Linux or if you are on Mac I think brew install coreutils gnu-sed bash
should get you the correct versions of date, sed and bash.
If running on macOS you'll need to change from date
to gdate
and that got it working for me!
Got super confused why you were passing a format to the daylight saving option '-d' then it clicked 😆 and I checked which date
returns /bin/date
belonging to the system and isn't the gnu one.
brew info coreutils
also mentions this:
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
I tried this on Manjaro linux and when I type "roam_wp" afterwards the terminal closes on me. Any idea why?
Thanks
@Singularity9 nope
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting this error when I run this: usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Any idea why this might be happening? Thanks for making this, by the way!