2020-07-27 17:00:26 +00:00
|
|
|
#!/usr/local/bin/fish
|
|
|
|
|
|
|
|
function notes --description "Notes functions"
|
|
|
|
|
2020-11-28 17:12:47 +00:00
|
|
|
set -gx NOTES_PATH $HOME/notes
|
2020-11-19 15:49:27 +00:00
|
|
|
|
|
|
|
function note_dates
|
|
|
|
set -g TODAY_NOTE (date +"%Y-%m-%d_%a")
|
|
|
|
set -g YESTERDAY_NOTE (date -jv "-1d" +"%Y-%m-%d_%a")
|
|
|
|
set -g TOMORROW_NOTE (date -jv "+1d" +"%Y-%m-%d_%a")
|
2020-12-04 01:22:44 +00:00
|
|
|
set -g LONG_DATE (date +"%A, %B %e, %Y" | sed 's/ */ /g')
|
|
|
|
set -g TODAY_NOTE_FILE $NOTES_PATH/journal/$TODAY_NOTE.md
|
2020-11-19 15:49:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function note_header
|
|
|
|
set -g CURRENT_WEATHER (curl -s "https://wttr.in/?format=1")
|
2020-12-04 01:22:44 +00:00
|
|
|
set -g JOURNAL_HEADER "[Yesterday]($YESTERDAY_NOTE.md) | [Home](home.md) | [Tomorrow]($TOMORROW_NOTE.md)\n\n$LONG_DATE\n$CURRENT_WEATHER\n#journal\n\n---\n\n# Today's Goals\n\n\n# Journal\n\n"
|
2020-11-19 15:49:27 +00:00
|
|
|
end
|
|
|
|
|
2020-07-27 17:00:26 +00:00
|
|
|
function journal --description "Create today's journal"
|
2020-11-19 15:49:27 +00:00
|
|
|
note_dates
|
2020-12-04 01:22:44 +00:00
|
|
|
if [ -f $TODAY_NOTE_FILE ]
|
2020-07-27 17:00:26 +00:00
|
|
|
echo "Already exists."
|
|
|
|
else
|
2020-11-19 15:49:27 +00:00
|
|
|
note_header
|
2020-12-04 01:22:44 +00:00
|
|
|
printf $JOURNAL_HEADER > $TODAY_NOTE_FILE
|
2020-07-27 17:00:26 +00:00
|
|
|
echo "New journal added."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-31 13:28:30 +00:00
|
|
|
function today --description "Open today's journal"
|
2020-11-19 15:49:27 +00:00
|
|
|
note_dates
|
2020-12-04 01:22:44 +00:00
|
|
|
if [ -f $TODAY_NOTE_FILE ]
|
|
|
|
vim $TODAY_NOTE_FILE
|
2020-07-31 13:28:30 +00:00
|
|
|
else
|
2020-11-19 15:49:27 +00:00
|
|
|
note_header
|
2020-12-04 01:22:44 +00:00
|
|
|
printf $JOURNAL_HEADER > $TODAY_NOTE_FILE
|
2020-07-31 13:28:30 +00:00
|
|
|
echo "New journal added."
|
2020-12-04 01:22:44 +00:00
|
|
|
vim $TODAY_NOTE_FILE
|
2020-07-31 13:28:30 +00:00
|
|
|
end
|
2020-11-19 15:49:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function meeting --description "Describe a meeting" -a "name"
|
|
|
|
note_dates
|
|
|
|
set today_date (date -j +"%Y-%m-%d")
|
|
|
|
set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]')
|
|
|
|
set meeting_name (echo $name | tr ' ' '-' | tr '[:upper:]' '[:lower:]')
|
|
|
|
set meeting_note $today_date-$meeting_name
|
2020-12-04 01:22:44 +00:00
|
|
|
printf "[$TODAY_NOTE](journal/$TODAY_NOTE.md) | #meeting\n\n# $name\n\n---\n\n" > $NOTES_PATH/$meeting_note.md
|
|
|
|
printf "\n\n---\n\n$time - [$name](../$meeting_note)\n\n---\n\n" >> $TODAY_NOTE_FILE
|
2020-11-19 15:49:27 +00:00
|
|
|
open "obsidian://open?vault=notes&file=$meeting_note"
|
2020-07-31 13:28:30 +00:00
|
|
|
end
|
|
|
|
|
2020-11-15 14:47:29 +00:00
|
|
|
function note --description "Edit or create a note" -a "filename"
|
|
|
|
if test -n "$filename"
|
2020-12-04 01:22:44 +00:00
|
|
|
vim $NOTES_PATH/$filename.md
|
2020-11-15 14:47:29 +00:00
|
|
|
else
|
2020-12-04 01:22:44 +00:00
|
|
|
set file (ls $NOTES_PATH | fzf)
|
2020-11-15 14:47:29 +00:00
|
|
|
if [ $status -eq 0 ]
|
2020-12-04 01:22:44 +00:00
|
|
|
vim $NOTES_PATH/$file
|
2020-11-15 14:47:29 +00:00
|
|
|
end
|
2020-07-31 13:28:30 +00:00
|
|
|
end
|
2020-11-19 15:49:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
abbr -a qn 'quicknote'
|
|
|
|
function quicknote --description "Write a quick note" -a "note"
|
|
|
|
note_dates
|
|
|
|
set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]')
|
2020-12-04 01:22:44 +00:00
|
|
|
printf "\n\n---\n\n#### $time\n$note\n" >> $TODAY_NOTE_FILE
|
2020-07-31 13:28:30 +00:00
|
|
|
end
|
|
|
|
|
2020-08-02 14:28:55 +00:00
|
|
|
abbr -a sn 'syncnotes'
|
|
|
|
function syncnotes --description "Full git commit on notes"
|
2020-11-19 15:49:27 +00:00
|
|
|
set current_dir $PWD
|
|
|
|
cd $NOTES_PATH
|
2020-08-02 14:28:55 +00:00
|
|
|
git pull
|
|
|
|
git add -A
|
|
|
|
git commit -m "autosync"
|
|
|
|
git push
|
2020-11-19 15:49:27 +00:00
|
|
|
cd $current_dir
|
2020-08-02 14:28:55 +00:00
|
|
|
end
|
|
|
|
|
2020-07-27 17:00:26 +00:00
|
|
|
end
|