Skip to content

Instantly share code, notes, and snippets.

@jujhars13
Created April 19, 2021 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jujhars13/060ff015181ef388ab46fc4550269730 to your computer and use it in GitHub Desktop.
Save jujhars13/060ff015181ef388ab46fc4550269730 to your computer and use it in GitHub Desktop.
vimNotes using vim to save my notes on a weekly basis (bound to super+N)
#!/bin/bash
# inspired by Leafshade software https://www.youtube.com/watch?v=zB_3FIGRWRU&t=333s
# daily notes
#noteFilename="$HOME/Dropbox/notes/notes/note-$(date +%Y-%m-%d).md"
# weekly notes
fileDate="$(date +%Y-%m-%d)"
if [[ "$(date +%a)" != "Mon" ]]; then
fileDate="$(date -dlast-monday +%Y-%m-%d)"
fi
noteFilename="$HOME/Dropbox/notes/notes/note-${fileDate}.md"
if [[ ! -f "${noteFilename}" ]]; then
echo "# Notes for $(date +%Y-%m-%d)" > "${noteFilename}"
fi
# go to end of file
# add subheading
# create two empty lines
# put cursor in the middle scroll
# put into insert mode
vim -c "norm Go" \
-c "norm Go## $(date '+%a %H:%M:%S')" \
-c "norm G2o" \
-c "norm zz" \
"${noteFilename}"
#-c "startinsert" "${noteFilename}" [0.09s]
@jujhars13
Copy link
Author

for Danny Burke

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