-
Notifications
You must be signed in to change notification settings - Fork 1
/
journal
46 lines (35 loc) · 910 Bytes
/
journal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
new-journal-entry() {
cd $JOURNAL_PATH
# Check if there is already a directory for the current year
year=$(date +"%Y")
if [ ! -d "$year" ]; then
mkdir $year
fi
cd $year
# Check if there is already a subdirectory for the current month
month=$(date +"%B")
if [ ! -d $month ]; then
mkdir $month
fi
cd $month
# Manage daily files
daily_file=$(date +"%d-%b-%Y")
entry=$(date +"%A, %d %B of %Y")
if [ ! -f "${daily_file}.md" ]; then
echo -ne "# $entry\n\n" > "${daily_file}.md"
fi
# New journal Entry
note_time=$(date +"%H:%M:%S")
echo -ne "## $note_time\n\n" > /tmp/journal_entry.md
vim -c 'startinsert' +2 /tmp/journal_entry.md
# Close up
echo -ne "\n" >> /tmp/journal_entry.md
cat /tmp/journal_entry.md >> "$daily_file".md
}
search-journal () {
grep -wihr --color=always "$1" $JOURNAL_PATH #| sed G
}
browse-entries () {
vim -c "NERDTree $JOURNAL_PATH"
}