-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes
More file actions
executable file
·54 lines (48 loc) · 846 Bytes
/
Copy pathnotes
File metadata and controls
executable file
·54 lines (48 loc) · 846 Bytes
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
#!/usr/bin/env zsh
function help() {
echo "Usage:
${SELF} [command [args]]
Commands:
add <note>
view [<dates>]
search <search terms>"
}
function print_notes() {
git log --pretty=format:"%cd %s" --date=short $@
}
# Go to the notes directory
NOTES_DIR=$(cd $(dirname $0); pwd)
cd "$NOTES_DIR"
# Get the command
COMMAND=$1
shift
case "${COMMAND}" in
"add")
NOTE="${@}"
if [[ ${#} -eq 0 ]]; then
help
exit 1
fi
git commit --allow-empty -m "${NOTE}" > /dev/null 2>&1
;;
"view")
DATE_STRING="${@}"
if [[ ${#} -gt 0 ]]; then
print_notes master@{"${DATE_STRING}"}
else
print_notes
fi
;;
"search")
SEARCH_TERMS="${@}"
print_notes -i --grep "${SEARCH_TERMS}"
;;
"sync")
git pull --rebase
git push
;;
*)
help
exit 0
;;
esac