psibi / tldr-hs

Haskell tldr client
BSD 3-Clause "New" or "Revised" License
93 stars 14 forks source link

Provide autocompletion #28

Closed septatrix closed 4 years ago

septatrix commented 4 years ago

The debian/ubuntu package does not provide autocompletion. I know this is the job of the shell - however one can provide a completion script. These would be installed in /etc/bash_completion.d/. One example is git which provides a shell script at /etc/bash_completion.d/git-prompt. Would it be possible to add such a script to the apt package? It could possible just delegate the work to /usr/share/bash-completion/bash_completion after stripping the first argument should it be tldr (and maybe also autocomplete the flags like --version and --update)

psibi commented 4 years ago

@septatrix

Would it be possible to add such a script to the apt package?

Unfortunately, I don't control how the apt package is distributed. But I could add a completion script with the repo, if it will help.

Also, you can probably add the completion script yourself into /etc/bash_completion.d/. You can use the tldr program itself to generate it:

$ tldr --bash-completion-script .
_tldr()
{
    local CMDLINE
    local IFS=$'\n'
    CMDLINE=(--bash-completion-index $COMP_CWORD)

    for arg in ${COMP_WORDS[@]}; do
        CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
    done

    COMPREPLY=( $(. "${CMDLINE[@]}") )
}

complete -o filenames -F _tldr tldr
septatrix commented 4 years ago

Oh I did not knew about that option and will definitely give it a try. Maybe you (as the developer) could also write an email to the debian packagers (pkg-haskell-maintainers@lists.alioth.debian.org)? This may help others in the future.

psibi commented 4 years ago

@septatrix Thanks, do let me know how it goes!

Maybe you (as the developer) could also write an email to the debian packagers (pkg-haskell-maintainers@lists.alioth.debian.org)? This may help others in the future.

I'm not sure I want to undertake that as I don't have sufficient bandwidth to do it. But if you want to do that, please go ahead and do it. :-) If there is any change required for this repository to accommodate Debian needs, I would happily do such change (or welcome any MR!).

psibi commented 4 years ago

@septatrix I'm closing the issue. Let me know if you disagree and want to re-open the issue. :-) Also free feel to ping me with any questions. Thanks!