-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathi3-notes
More file actions
executable file
·73 lines (50 loc) · 1.52 KB
/
i3-notes
File metadata and controls
executable file
·73 lines (50 loc) · 1.52 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
#!/usr/bin/bash
terminal="i3-sensible-terminal"
editor="i3-sensible-editor"
notes_directory="${HOME}"/.notes
if [[ ! -d "${notes_directory}" ]]
then
mkdir -p "${notes_directory}"
fi
separator=" // "
font_name="Monospace"
font_size=10
font="${font_name}:size=${font_size}"
lines=15
prompt="NOTES${separator}"
list="$(find -L ${notes_directory} -maxdepth 1 -type f | sed 's|^"${notes_directory}/""||' | sort)"
selection="$(echo -e "${list}" | dmenu -i -l "${lines}" -p "${prompt}" -fn "${font}" -nb '#000000' -nf '#FFFFFF' -sb '#666666' -sf '#000000')"
note_slugger () {
echo ${@} | tr -d '[:punct:]' \
| sed -e "s/ /-/g" \
-e "s/[áàãâ]/a/g" \
-e "s/[éê]/e/g" \
-e "s/[íÍ]/i/g" \
-e "s/[óõô]/o/g" \
-e "s/[úü]/u/g" \
-e "s/[ç]/c/g"
}
note_create () {
extension="md"
file_name="$(note_slugger "${1,,}")"
file_name="${file_name}.${extension}"
note="${notes_directory}/${file_name}"
title="${1,,}"
title=${title^^}
echo -e "# ${title}\n\n" > "${note}"
notify-send -i "Notes" "New note" "Note <b>$file_name.md</b> was created under '${notes_directory}'"
}
note_open () {
note_selection="${notes_directory}/${selection}"
if [[ ! -f "${note_selection}" ]]
then
note_create "${selection}"
else
note="${note_selection}"
fi
eval "$(${terminal} -T "Notes" -e "${editor} +$(wc -l ${note}) ${note}")"
}
if [[ ! -z "${selection}" ]]
then
note_open
fi