-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneovim-quick-note.sh
executable file
·67 lines (56 loc) · 1.63 KB
/
neovim-quick-note.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# -*- coding: UTF-8 -*-
: "${ME:=$HOME/Me}"
description=$*
# Default notification system is stdout
WARNING="echo [!]"
command -v termux-setup-storage >/dev/null 2>&1
in_termux=$?
if command -v notify-send > /dev/null; then
WARNING="notify-send --app-name QuickNote -i dialog-warning"
fi
if [ "$in_termux" -eq 0 ]; then
ME=$HOME/storage/documents/Me
WARNING="termux-notification --content"
fi
if [ -z "$description" ]; then
if [ "$in_termux" -eq 0 ]; then
description=$(termux-dialog text -m -t "What are you thinking?" -i "I conquered the world today" | jq -r .text)
else
description=$(kdialog --geometry 600x100+200+200 --title QuickNote --textinputbox "What are you thinking?")
fi
fi
# if description is still empty we must exit
if [ -z "$description" ]; then
echo "No description"
exit 0
fi
noteDirectory="$ME/Notes"
noteFilename="${noteDirectory}/Journal/$(date +%Y-%m-%d.md)"
if [[ ! -f "$noteFilename" ]]; then
# Template will be
#
# Last:
# . week: [[7 days ago link]]
# . month: [[1 month ago link]]
# . year: [[1 year ago link]]
cat << EOF > "$noteFilename"
Last:
. week: [[$(date -d "last week" +%Y-%m-%d)]]
. month: [[$(date -d "last month" +%Y-%m-%d)]]
. year: [[$(date -d "last year" +%Y-%m-%d]]
)## $(LC_TIME=C date +"%d %a")
EOF
fi
rc=$?
if [ $rc -ne 0 ]; then
$WARNING "could not create note $noteFilename: error $rc"
exit 1
fi
echo ""; LC_TIME=C date +"%H:%M" >> "$noteFilename"
echo "$description" >> "$noteFilename"
if [ "$in_termux" -eq 0 ]; then
"$HOME"/workspace/script/neovim-weekly-review.sh
else
neovim-weekly-review.sh
fi