todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.55k stars 712 forks source link

Allow to select task via fuzzyfind (fzf) #437

Closed thrien closed 1 month ago

thrien commented 1 month ago

Feature Request

Allow to select a task by content instead of linenumber, e.g. via a fuzzyfinder. In all cases where a mandatory task is not provided it is chosen interactively.

Example

I've used fzf as a convenient fuzzyfinder on the commandline to show how this could work:

todo_fzf

If you don't specify a linenumber you get an interactive prompt to select one.

For this simple preview I changed line 1224 to:

    [ "$#" -eq 0 ] && set -- "$(_list "$TODO_FILE" | fzf --height=~10 | awk '{ print $1 }')"

Implementation

I need some guidance by someone more familiar with the code to come up with a proper implementation.

pabgan commented 1 month ago

You can do it with an alias:

todo.sh do $(todo.sh ls | head -n-2 | fzf --ansi | cut -d' ' -f1)

I think maintainers wants to keep main script as simple as possible.

thrien commented 1 month ago

Okay, fair enough. Maybe that's a feature for one of the many apps built on top of it.

Then let me just mention for future reference how to use dmenu in this case. With these two patches

it can be nicely integrated as follows

dmenu -w "$WINDOWID" -F -ix -p "Select a task:" < "$TODO_FILE" | xargs expr 1 +