diff --git a/README.md b/README.md index 594cb9e4..2601c7d9 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,18 @@ For example, to add a todo item, you can do: ```shell todo.sh add "THING I NEED TO DO +project @context" ``` +### `replace` +Replaces task on line ITEM# with UPDATED TODO. + +```shell +todo.sh replace ITEM# "UPDATED TODO" +``` +### `report` +Adds the number of open tasks and done tasks to report.txt. + +```shell +todo.sh report +``` Read about all the possible commands in the [USAGE][USAGE] file. diff --git a/todo.sh b/todo.sh index 026739a5..4d78ebc7 100755 --- a/todo.sh +++ b/todo.sh @@ -1089,6 +1089,13 @@ case $action in fi _addto "$TODO_FILE" "$input" ;; +"search") + shift + if [ -z "$1" ]; then + die "usage: $TODO_SH search [KEYWORD...]" + fi + grep -i "$@" "$TODO_FILE" + ;; "addm") if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then @@ -1098,6 +1105,18 @@ case $action in shift input=$* fi +"renameproj") + if [ -z "$2" ]; then + die "usage: $TODO_SH renameproj +oldproject +newproject" + fi + old_project=$1 + new_project=$2 + if ! grep -q "$old_project" "$TODO_FILE"; then + die "Project $old_project not found in $TODO_FILE" + fi + sed -i.bak "s/$old_project/$new_project/g" "$TODO_FILE" + echo "Renamed project $old_project to $new_project in $TODO_FILE" + ;; # Set Internal Field Seperator as newline so we can # loop across multiple lines