summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp4bl0 <r _at_ uzy .dot. me>2018-07-01 10:49:52 (CEST)
committerp4bl0 <r _at_ uzy .dot. me>2018-07-01 10:49:52 (CEST)
commit8f8cc3c1cde64e845f1a0bf902fdf10aba1cc5c8 (patch)
treeaa3582aea83f2542268599da66a41d9cd638108d
parent3a0e84c9ccc592207ee912ff75b138f752b9237b (diff)
downloadmyutils-8f8cc3c1cde64e845f1a0bf902fdf10aba1cc5c8.zip
myutils-8f8cc3c1cde64e845f1a0bf902fdf10aba1cc5c8.tar.gz
allow to edit todo itemsHEADmaster
-rwxr-xr-xtodo32
1 files changed, 27 insertions, 5 deletions
diff --git a/todo b/todo
index 7b6c21b..6b1aef4 100755
--- a/todo
+++ b/todo
@@ -20,11 +20,12 @@ Usage: todo list: list items.
todo i m: add important item m.
todo u m: add urgent item m.
todo iu m: add urgent and important item m.
+ todo edit n m: edit item #n.
todo delete n: delete item #n.
- todo edit n l: set level of item #n to l (t, i, u, iu).
+ todo move n l: set level of item #n to l (t, i, u, iu).
todo help: show this help.
First letter of each command could be used in place of the command.
-
+
You can specify a memo file with the -f option before the command.
The default memo file is the value of the \$TODO environment variable,
or ~/.todo if \$TODO isn't set or empty.
@@ -77,6 +78,26 @@ _todo_add(){
_todo_display_item $*
}
+_todo_edit() {
+ n="$1"
+ shift
+ m="$*"
+ i=1;
+ while read item; do
+ if [ $i -ne $n ]; then
+ echo "$item"
+ else
+ _todo_echo -n white "Edited: " >&2
+ _todo_display_item $item >&2
+ item=($item)
+ _todo_echo -n white "is now: " >&2
+ _todo_display_item ${item[0]} $m >&2
+ echo ${item[0]} $m
+ fi
+ i=$(( i + 1 ))
+ done < "$TODO" | sponge "$TODO"
+}
+
_todo_delete(){
n="$1"
if [ "$n" = "all" ]; then
@@ -99,7 +120,7 @@ _todo_delete(){
done < "$TODO" | sponge "$TODO"
}
-_todo_edit() {
+_todo_move() {
n="$1"
level="$2"
i=1;
@@ -107,7 +128,7 @@ _todo_edit() {
if [ $i -ne $n ]; then
echo "$item"
else
- _todo_echo -n white "Edited: " >&2
+ _todo_echo -n white "Moved: " >&2
_todo_display_item $item >&2
item=($item)
unset -v item[0]
@@ -133,7 +154,8 @@ shift
case "$action" in
l|list) _todo_list ;;
u|i|ui|iu|t) _todo_add $action "$@" ;;
- d|delete) _todo_delete "$@" ;;
e|edit) _todo_edit "$@" ;;
+ d|delete) _todo_delete "$@" ;;
+ m|move) _todo_move "$@" ;;
h|help|*) _todo_usage >&2 ;;
esac
Pablo Rauzy — generated by cgit