-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtodo
More file actions
executable file
·31 lines (27 loc) · 793 Bytes
/
todo
File metadata and controls
executable file
·31 lines (27 loc) · 793 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
#!/bin/sh
#
# Write/remove a task to do later.
#
# Select an existing entry to remove it from the file, or type a new entry to
# add it.
#
file="$HOME/projects/notas/trabalho/athenaworks/uberall/uberall-todo.md"
done="$HOME/projects/notas/trabalho/athenaworks/uberall/todo-concluded.md"
touch "$file"
touch "$done"
height=$(wc -l "$file" | awk '{print $1}')
prompt="Add/delete a task: "
cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
while [ -n "$cmd" ]; do
if grep -q "^$cmd\$" "$file"; then
grep -v "^$cmd\$" "$file" > "$file.$$"
when=$(date "+%Y-%m-%d_%R")
echo "$cmd" - "$when" >> "$done"
mv "$file.$$" "$file"
height=$(( height - 1 ))
else
echo "$cmd" >> "$file"
height=$(( height + 1 ))
fi
cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
done