Last active
May 10, 2021 13:17
-
-
Save Khazl/78b18476e04dd94904dedde53f17bb1c to your computer and use it in GitHub Desktop.
Daily Notes. Script which creates a markdown file based on the current date and starts the editor.
This file contains 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
const fs = require('fs') | |
const { exec } = require('child_process') | |
function paddedZero(value) { | |
return (`0${value}`).slice(-2) | |
} | |
let today = new Date() | |
today = `${today.getFullYear()}-${paddedZero(today.getMonth()+1)}-${paddedZero(today.getDate())}` | |
if (!fs.existsSync(`${today}.md`)) { | |
fs.appendFile(`${today}.md`, `# Notes for ${today}\n\n- `) | |
} | |
// Works in macOS and with typora as markdown editor. Change regarding your environment or md tool. | |
exec(`open -a typora ${today}.md`) | |
// Windows example | |
// exec(`notepad ${today}.md`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
daily-notes/
node index.js
(or create some alias for this command)