-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearn.bash
More file actions
executable file
·88 lines (74 loc) · 1.89 KB
/
Copy pathlearn.bash
File metadata and controls
executable file
·88 lines (74 loc) · 1.89 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# show notes, step by step on selected tag
project_dir=$(dirname $0)
quite="exit"
tags=$(cat $project_dir/tags)
PS3="Select tag: "
SCREEN_WIDTH=$(tput cols)
. $project_dir/colors.bash
. $project_dir/interactive.bash
function close_app
{
kill %1 2>/dev/null
exit
}
function pomodoro
{
kill %1 2>/dev/null
sleep 25m && notify-send "Take a break" "Relax and drink a cup of tea" &
}
function hr
{
printf '%*s\n' "${1}" '' | tr ' ' -
}
function not_continue
{
echo
echo -n "Continue? [y/n] "
read answer
if [[ $answer = "n" ]]; then
close_app
fi
}
function show_note
{
current_number=$(echo "$1" | rev | cut -d'/' -f1 | rev | cut -d'.' -f1)
local counter="[ $current_number/$total_number_of_notes ]"
local counter_size=${#counter}
local note_header_text="[ NOTE ]"
local note_header_size=${#note_header_text}
local note_header="${black}${bg_green}\e[1m$note_header_text${reset}"
local note_path_size=${#1}
local line_size=$(echo "$SCREEN_WIDTH-$note_header_size-$counter_size-$note_path_size-3" | bc)
local line=$(hr $line_size)
clear
echo -e "$note_header $counter $1 $line"
echo
cat $1 | $project_dir/render_markdown.bash
}
function main
{
pomodoro
clear
select tag in $quite $tags
do
if [[ $tag = $quite ]]; then
close_app
fi
if [[ -n $tag ]]; then
local tag_path=$project_dir/content/$tag
local list_of_notes=$(ls -1 $tag_path | sort -n)
total_number_of_notes=$(echo "$list_of_notes" | wc -l)
for note in $list_of_notes
do
show_note "$tag_path/$note"
if [[ $current_number -eq $total_number_of_notes ]]; then
not_continue
main
fi
not_continue
done
fi
done
}
main