-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotesrc
More file actions
45 lines (41 loc) · 1.01 KB
/
notesrc
File metadata and controls
45 lines (41 loc) · 1.01 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
notes_changed() {
test -n "$(git status --porcelain)"
}
notes() {
export GIT_WORK_TREE="$NOTES_DIR"
export GIT_DIR="$NOTES_DIR/.git"
if [ "$1" = "ls" ]; then
if [ "$2" != "" ]; then
ls "$NOTES_DIR/$2"
else
ls "$NOTES_DIR"
fi
elif [ "$1" = "edit" ]; then
if [ "$2" != "" ]; then
vim "$NOTES_DIR/$2"
if notes_changed; then
git add .
git commit -m "Update $2" -e
fi
else
echo "Usage: notes edit path/to/file"
fi
elif [ "$1" = "sync" ]; then
git pull -r
if notes_changed; then
echo "Merge conflicts in notes, must resolve manually"
cd "$NOTES_DIR"
else
git push
fi
else
echo "Usage: notes [ls, edit, sync]"
fi
unset GIT_WORK_TREE
unset GIT_DIR
}
inbox() {
echo $1 >> $NOTES_DIR/inbox.org
}
alias todo='notes edit todo.org'
alias today='notes edit today.md'