-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_entry.sh
44 lines (35 loc) · 958 Bytes
/
new_entry.sh
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
#!/bin/bash
# Create a timestamp in ISO 8601 format (YYYY-MM-DD) (the best one)
NOW=$(date +"%Y-%m-%d")
# Create a file with the name "YYYY-MM-DD.md" inside the data directory
# For that, check if a file like that already exists, if so, do nothing and exit
FILE=./data/$NOW.md
if test -f "$FILE"; then
echo "$FILE already exists."
exit
fi
# If we arrive here, the file does not exist, so we can actually create it
echo "Generating $FILE"
touch $FILE
# Here you can echo whatever you want into the file, creating sections or whatever you want
# I for example want something that looks like this:
# #############
# # 2022-10-16
#
# ## Work
#
#
# ## Private
#
# #############
# Just adapt everything between the `cat` and the `EOF` line
cat << EOF > $FILE
# $NOW
## Work
## Private
EOF
# Open the file in an editor (you can adapt this line to an editor of your choice)
echo "Waiting for editor to close"
vim $FILE
# We're done
echo "Done"