Skip to content

Instantly share code, notes, and snippets.

@Khazl
Last active May 10, 2021 13:17
Show Gist options
  • Save Khazl/78b18476e04dd94904dedde53f17bb1c to your computer and use it in GitHub Desktop.
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.
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`)
@Khazl
Copy link
Author

Khazl commented May 10, 2021

  1. Download the file
  2. Place in some directory like daily-notes/
  3. Adjust script regarding your environment and needs
  4. Execute with node index.js (or create some alias for this command)
  5. Write your notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment