-
Notifications
You must be signed in to change notification settings - Fork 6
/
zshnotes.plugin.zsh
62 lines (56 loc) · 1.81 KB
/
zshnotes.plugin.zsh
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
#!/bin/zsh
# Written 7/22/20 by Jake Gearon; jake.gearon@gmail.com
note_submit() {
local cur_time
cur_time="$(date +"%r"): "
local cur_day
cur_day=$(date +"%m-%d-%y")
local day_path
day_path="$HOME/Documents/zshnotes/"$cur_day".txt"
task=$(echo -E "$@" | tr '\n' '\000' | sed 's:\x00\x00.*:\n:g' | tr '\000' '\n')
if [[ ! -e $day_path ]]; then
mkdir -p $HOME/Documents/zshnotes
touch $day_path
chmod +x $day_path
fold -w 80 -s $day_path
echo "##########################################################" >> $day_path
echo "############### DAILY NOTES FOR" $cur_day "################" >> $day_path
echo "##########################################################\n" >> $day_path
echo "$cur_time $task" >> $day_path
echo "--" >> $day_path
else
echo "$cur_time $task" >> $day_path
echo "--" >> $day_path
fi
}
autoload -U note_submit
alias note=note_submit
note_read() {
local cur_day
cur_day=$(date +"%m-%d-%y")
local day_path
day_path="$HOME/Documents/zshnotes/"$cur_day".txt"
if [[ ! -e $day_path ]]; then
mkdir -p $HOME/Documents/zshnotes
touch $day_path
chmod +x $day_path
fold -w 80 -s $day_path
echo "##########################################################" >> $day_path
echo "############### DAILY NOTES FOR" $cur_day "################" >> $day_path
echo "##########################################################\n" >> $day_path
cat "$day_path"
else
cat "$day_path"
fi
}
alias cnote=note_read
autoload -U note_read
note_read_yest() {
local cur_day
y_day=$(date -v-1d +"%m-%d-%y")
local day_path
day_path="$HOME/Documents/zshnotes/"$y_day".txt"
cat $day_path
}
alias ynote=note_read_yest
autoload -U note_read_yest