ja-he / dayplan

A utility to plan and track your time.
MIT License
5 stars 1 forks source link

Add bash completion #18

Closed ja-he closed 2 months ago

ja-he commented 2 years ago

go-flags allows for low-effort completion by running the binary with GO_FLAGS_COMPLETION=1; then all it takes is this completion script to be sourced to /usr/share/bash-completion/completions.

_dayplan_completion() {
    args=("${COMP_WORDS[@]:1:$COMP_CWORD}")

    local IFS=$'\n'

    COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
    return 0
}

complete -F _dayplan_completion dayplan

From my testing, it does overcomplete a bit, but I think usage is a bit too flexible for me to want to write the bash completion manually.

ja-he commented 2 months ago

I did this for the AUR package, so I guess this is done? Not so crucial at least.