summaryrefslogtreecommitdiff
path: root/todo
diff options
context:
space:
mode:
authorfilip <“filip.rabiega@gmail.com”>2025-10-14 21:57:25 +0200
committerfilip <“filip.rabiega@gmail.com”>2025-10-14 21:57:25 +0200
commit91a4eacb0419bd0f67774f6124b6f0b1525eb988 (patch)
treede8189790a11437e540f7792fd7559f88212bae7 /todo
parent7f6189dcbed755af34e222237b8cfa8b1f903696 (diff)
downloadchadscripts-91a4eacb0419bd0f67774f6124b6f0b1525eb988.tar.gz
chadscripts-91a4eacb0419bd0f67774f6124b6f0b1525eb988.tar.bz2
chadscripts-91a4eacb0419bd0f67774f6124b6f0b1525eb988.zip
new stuff
Diffstat (limited to 'todo')
-rwxr-xr-xtodo28
1 files changed, 28 insertions, 0 deletions
diff --git a/todo b/todo
new file mode 100755
index 0000000..fbb893b
--- /dev/null
+++ b/todo
@@ -0,0 +1,28 @@
+#!/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/.local/opt/todo"
+touch "$file"
+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.$$"
+ mv "$file.$$" "$file"
+ height=$(( height - 1 ))
+ else
+ echo "$cmd" >> "$file"
+ height=$(( height + 1 ))
+ fi
+
+ cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
+done
+
+exit 0