Skip to content

Interactive CLI choosing mode (interactive task listing with filtering) #641

Answered by kerma
iangregsondev asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @iangregsondev! You could achieve something like this using fzf:

task -l | grep -v 'task: Available' | fzf --prompt="Available tasks: " | awk '{sub(/:$/, "", $2); print $2}' | xargs task

It needs a bit more work to get it properly working inside taskfile itself however.


EDIT: Here's a full example that works defined within taskfile itself:

version: '3'

vars:
  GREETING: Hello, World!

tasks:
  hello:
    desc: "say hello"
    cmds:
      - echo "{{.GREETING}}"
    silent: true

  default:
    cmds:
      - | 
        selected=$(task -l | grep -v "task: Available" | fzf --prompt="task:")
        echo "$selected" | awk '{sub(/:$/, "", $2); print $2}' | xargs task
    silent: true

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@vctls
Comment options

Answer selected by kerma
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #640 on December 25, 2021 10:26.